Arguments satisfy for a range of n when I use stepseq function
조회 수: 8 (최근 30일)
이전 댓글 표시
I receive an error ' arguments must satisfy n1 <= n0 n<= n2' for the below rectangular function.
How can I fix this error?
-----------------------------------------------------------------------------------------------------
% Define variables
n= -40:40;
nlower=n(1);
nupper=n(end);
M1=[10,25,50,101]
for m=1:4
M=M1(m);
rec=stepseq(0,nlower,nupper)-stepseq(M,nlower,nupper)
% Calculating DTFT
subplot(3,1,1);
w= (-100:100)*pi/100;
Rec=dtft(rec,n,w);
end
댓글 수: 0
답변 (1개)
Walter Roberson
2023년 2월 19일
nlower is -40, nupper is +40.
M1(3) = 50 is not in the range -40 to +40, so when you call stepseq(50, -40, +40) then you get the error message.
Note that stepseq() is a third-party function, not provided by Mathworks. It appears to have been designed to create a vector of 0 from (integer) nlower to the value of the first parameter, and then 1 from there to (integer) nupper. The behaviour if the first parameter is out of range is not well defined -- should it create a vector of false values from the given value to the lower bound if it is below the lower bound? Should it create a vector of false values from the upper bound to the value if it is greater than the upper bound? The result would be of variable length, which would not be in keeping the the expected uses of stepseq of returning a fixed-length result.
댓글 수: 2
Walter Roberson
2023년 2월 19일
You do not have hold on so each M value is going to overwrite the previous plots.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!