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

Torsten
Torsten 2022년 5월 17일
Check whether you have the Signal Processing Toolbox installed and licensed.

댓글을 달려면 로그인하십시오.

 채택된 답변

KSSV
KSSV 2022년 5월 17일

0 개 추천

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

Arkadius882
Arkadius882 2022년 5월 17일
Still doesn't work. Used clear command, even copied the code to another function and there's still the same error.
What does which square gives..?
which square
/MATLAB/toolbox/signal/signal/square.m
Arkadius882
Arkadius882 2022년 5월 17일
Okay, I finally managed to fix it. As you said the problem was that I named function square and despite using clear square the problem still occured. I had to delete that badly named function. Thanks a lot!
KSSV
KSSV 2022년 5월 17일
One should avoid naming function name/ variable name with inbuilt function names.
:)
Arkadius882
Arkadius882 2022년 5월 17일
Now I know it, thank you again :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 5월 17일

댓글:

2022년 5월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by