Error using plot Invalid data argument.
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
i am trying to plot x(t) = 2[u(t)-u(t-1)]
here are my steps including function y = U(t)
function y = U(t)
t = -3:0.0001:3;
y= 1*(t>=0);
plot(t,U(t))
xlabel ('t')
ylabel('y')
axis([-3 3 -1 2])
grid on
title('plot of the unit step function U(t)')
end
x(t) = 2[U(t)-U(t-1)]
x = @(t) 2*(U(t)-U(t-1))
plot(t,x(t))
1 Commento
Alexandra McClernon Ownbey
il 28 Mar 2020
What is the error you are getting? Make sure you define subfunctions at the end of the script.
Risposte (1)
Adam Danz
il 28 Mar 2020
Modificato: Adam Danz
il 31 Mar 2020
function y = U(t)
t = -3:0.0001:3;
y= 1*(t>=0);
plot(t,U(t))
% ^^^^problem
You're recursively calling the U(t) function from within the function.
When sharing an error message, please share the entire copy-pasted message.
3 Commenti
Adam Danz
il 31 Mar 2020
That line is also invalid because t are floating point numbers rather than index values.
Vedere anche
Categorie
Scopri di più su Visual Exploration in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!