- Put parentheses around the ‘t’ after the ‘@’ operator;
- use element-wise operations in your ‘v1’ anonymous function;
- call ‘v1’ as a function in your plot call.
I keep getting an error message on this code, I dont know what the problem is. Keeps saying the expression is invalid
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Reyly Bonilla
il 16 Nov 2018
Commentato: Star Strider
il 16 Nov 2018
>>t = [0:10];
>>v1 = @t (2cos(t)-sin(t))*25*exp(-t);
>>plot(t,v1);
0 Commenti
Risposta accettata
Star Strider
il 16 Nov 2018
Modificato: Star Strider
il 16 Nov 2018
You need to:
Try this:
t = [0:10];
v1 = @(t) (2*cos(t)-sin(t))*25.*exp(-t);
plot(t,v1(t));
EDIT —
Also, you need to provide operators (such as ‘*’ and ‘.*’), since MATLAB does not recognise implied multiplication.
2 Commenti
Star Strider
il 16 Nov 2018
My pleasure.
If my Answer helped you solve your problem, please Accept it!
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!