Solving system of multiple input in ODE

hi, please help me with this problem
I'm trying to solve system of ODEs with multiple input of "v", I think I have issue with loops, so result looks incorrect
function dxdt = PTVP2 (t, x)
load('input.mat');
switch road
case 1
y = (d_2/2)*sin(2*pi*t*fq);
case 2
if t < (3.6*d_1)/(2*v2)
y = d_2*sin((2*pi*v2*t)/(3.6*d_1)).^2;
else
y = 0;
end
end
dxdt(1) = x(2);
dxdt(2) = (k_s/m_u)*(x(3)-x(1))+(c_s/m_u)*(x(4)-x(2))-(k_u/m_u)*(x(1)-y);
dxdt(3) = x(4);
dxdt(4) = -(k_s/m_s)*(x(3)-x(1))-(c_s/m_s)*(x(4)-x(2));
dxdt = dxdt(:);
end
v21 = ([0:1:120])';
x_extend = zeros(length(v21),1);
x_compress = zeros(length(v21),1);
for i=1:1:length(v)
v2=v21(i);
save input.mat
[T2, X2]= ode45(@PTVP2, TSPAN, IC,options)
a=X2(:,3)-X2(:,1);
x_extend(i) = max(a);
x_compress(i) = min(a);
end
plot(v21,x_extend)
hold on
plot(v21,x_co
X2 is 41x1 which I think its wrong
graph is just a straigth line at 0
please help, thank you so much

Respuestas (0)

La pregunta está cerrada.

Preguntada:

el 20 de Oct. de 2020

Cerrada:

el 21 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by