Solving ODE two sets of initial conditions
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Star Strider
2015-11-5
I may be missing something, but it seems you already have:
y0 = [-1;1]; % set initial condition
5 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!