Solving ODE two sets of initial conditions
1 view (last 30 days)
Show older comments
I have to solve the equation yp = [y(2);(-(z*y(2)+w*y(1)+beta*y(2)^3+n*y(1)^3))]; and display the results in a phase plot. How do I include initial conditions for both the displacement and the velocity? Here is my code:
function [t,y] = call_trial1()
tspan = [0 5]; % set time interval
y0 = [-1;1]; % set initial condition
[t,y] = ode15s( @trial1 ,tspan ,y0);
plot(t,y)
xlabel('Structural Displacement(m)')
ylabel('Structural Velocity(m/s)')
grid on
disp([t,y]) % displays t and y(t)
function yp = trial1 (t,y)
m=1.2; c=4; k=1600;
cf=-8; kf=100; beta=20; n=-2.5;
z=(cf-c)/m; w=(kf-k)/m;
yp = [y(2);(-(z*y(2)+w*y(1)+beta*y(2)^3+n*y(1)^3))];
end
end
0 Comments
Answers (1)
Star Strider
on 5 Nov 2015
I may be missing something, but it seems you already have:
y0 = [-1;1]; % set initial condition
5 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!