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!