Mathematica
Remove["Global`*"];
sol = First@DSolve[{y'[t]==3y[t],
y[0]==1},y[t],t];
y = y[t]/.sol
Out[26]= E^(3 t)
Plot[y,{t,0,2},
FrameLabel->{{"y(t)",None},
{"t","Solution of y'=3y, y(0)=1"}},
Frame->True,
GridLines->Automatic,
GridLinesStyle->Automatic,
RotateLabel->False,
ImageSize->300,
AspectRatio->1]
|
Matlab
function e53
t = 0:0.001:2; % time
initial_y = 1;
[t,y] = ode45( @rhs, t, initial_y);
plot(t,y)
title('Solution of y''=3y , y(0)=1');
xlabel('time');
ylabel('y(t)');
grid on
set(gcf,'Position',[10,10,420,420]);
function dydt=rhs(t,y)
dydt = 3*y;
end
end
|