Arguments satisfy for a range of n when I use stepseq function
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 19 Feb. 2023
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 Kommentare
Gizem Karslioglu
am 19 Feb. 2023
Bearbeitet: Walter Roberson
am 19 Feb. 2023
Walter Roberson
am 19 Feb. 2023
You do not have hold on so each M value is going to overwrite the previous plots.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
