"must return a column vector" ODE45
Afficher commentaires plus anciens
Hi all, I am trying to solve a free vibration response problem using ode45, and keep getting the same error. My code is as follows:
%%SOLVE SYSTEM OF (TWO) ODES
clear;clc;close all;
%%Set initial conditions
global xst F d Wn Wd
xst = 4.81548E-05
t = [0 (15*pi*50)]
F = 940
d = 0.05
x = 0.00021
M = 220
rmax = 0.997496867
k = F/(x*((((1-rmax^2)^2)+(4*(d^2)*(rmax^2)))^0.5))
W = 15*pi
Wn = (k/M).^0.5
c = 2*d*Wn
Ft = x*(((k.^2)+(c.^2)*(W^2)).^0.5)
Wd = 450.787
%%Calculate solution for single ODE
[t,x] = ode45(@systemODEfunc,[0 50],[xst, 0]);
%%Plot results
plot(t,y(:,1),'- red',t,y(:,2), '- blue')
With the ode45 function being:
function y = systemODEfunc(t,x)
global xst F d Wn Wd
y = zeros(50,2)
%Evaluate x(t)
y(t+1,1) = (exp((-d*Wn*t)))*(xst*cos(Wd*t))
%Evaluate dx(t)
y(t+1,2) = (exp(-d*Wn*t))*(((-d*Wn*(xst*cos(Wd*t)))+(Wd*(-xst*sin(Wd*t)))))
end
No matter what I try I seem to always get the following:
Error using odearguments (line 90)
SYSTEMODEFUNC must return a column vector.
Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in systemODE (line 22)
[t,x] = ode45(@systemODEfunc,[0 50],[xst, 0]);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!