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

回答(1 个)

Star Strider
Star Strider 2015-11-5
I may be missing something, but it seems you already have:
y0 = [-1;1]; % set initial condition
  5 个评论
moonman1
moonman1 2015-11-5
this is the equation i want to model. what is the best way to write it in matlab

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by