Arguments satisfy for a range of n when I use stepseq function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 19 Fév 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 commentaires
Gizem Karslioglu
le 19 Fév 2023
Modifié(e) : Walter Roberson
le 19 Fév 2023
Walter Roberson
le 19 Fév 2023
You do not have hold on so each M value is going to overwrite the previous plots.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!