Filter löschen
Filter löschen

How can I graph exponential functions?

2 Ansichten (letzte 30 Tage)
MC
MC am 13 Sep. 2019
Beantwortet: Star Strider am 13 Sep. 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

Antworten (1)

Star Strider
Star Strider am 13 Sep. 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.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by