Borrar filtros
Borrar filtros

How can I graph exponential functions?

2 visualizaciones (últimos 30 días)
MC
MC el 13 de Sept. de 2019
Respondida: Star Strider el 13 de Sept. de 2019
f = @(t,y) 2*y+4-t;
t = 0:0.05:0.5;
y = -2:0.05:-1.5;
dirfield(f,t,y)
hold on
t = linspace(0,5,100);
y1 = (2*exp(-2*t)-7*exp(-2*t)+0.6)/(4*exp^(-2*t));
y2 = (2*exp(-2*t)-7*exp(-2*t)+0.2)/4*exp^(-2*t);
y3 = (2*exp(-2*t)-7*exp(-2*t)-0.2)/4*exp^(-2*t);
y4 = (2*exp(-2*t)-7*exp(-2*t)-0.6)/4*exp^(-2*t);
plot(t,y1,'b',t,y2,'b',t,y3,'b',t,y4,'b')
hold off
savefig('M1.fig')
Error Message=
Error in M1 (line 7)
y1 = (2*exp(-2*t)-7*exp(-2*t)+0.6)/(4*exp^(-2*t));
M1
Error using exp
Not enough input arguments, I want to graph the differential euqations with various IVP
Thanks

Respuestas (1)

Star Strider
Star Strider el 13 de Sept. de 2019
First, do not use the exponentiation operator here:
y1 = (2*exp(-2*t)-7*exp(-2*t)+0.6)/(4*exp^(-2*t));
and use element-wise multiplication (.*) and division (./) operations:
y1 = (2*exp(-2*t)-7.*exp(-2*t)+0.6)./(4*exp(-2*t));
Do the same with all of them, and remember the parentheses in the denominator on the others.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by