Too many input arguments using square

2 views (last 30 days)
As the title says for some reason square command has too many input arguments I don't know why. Done the same example a while ago and all worked.
tmax=9e-3;
T=3e-3;
Umax=2;
Umin=-3;
N=19;
a=0.6;
wo=(2*pi)/T;
t=linspace(0,tmax,2001);
U=square(wo*t,100*a);
U=0.5*(Umax-Umin)*U+0.5*(Umax+Umin);
td=linspace(0,tmax,N);
Ud=square(wo*td,100*a);
Ud=0.5*(Umax-Umin)*Ud+0.5*(Umax+Umin);
close all;
plot(t,U,'b');
grid on; zoom on; hold on;
stem(td,Ud,'r*');
  1 Comment
Torsten
Torsten on 17 May 2022
Check whether you have the Signal Processing Toolbox installed and licensed.

Sign in to comment.

Accepted Answer

KSSV
KSSV on 17 May 2022
Code is working fine. It seems you have introduced a variable named square. Clear it and then run the function. REad about clear
clear square
tmax=9e-3;
T=3e-3;
Umax=2;
Umin=-3;
N=19;
a=0.6;
wo=(2*pi)/T;
t=linspace(0,tmax,2001);
U=square(wo*t,100*a);
U=0.5*(Umax-Umin)*U+0.5*(Umax+Umin);
td=linspace(0,tmax,N);
Ud=square(wo*td,100*a);
Ud=0.5*(Umax-Umin)*Ud+0.5*(Umax+Umin);
close all;
plot(t,U,'b');
grid on; zoom on; hold on;
stem(td,Ud,'r*');
  5 Comments
KSSV
KSSV on 17 May 2022
One should avoid naming function name/ variable name with inbuilt function names.
:)
Arkadius882
Arkadius882 on 17 May 2022
Now I know it, thank you again :)

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!