Iam getting an error with the ODE45 function (line 90)and (line 115)?
1 view (last 30 days)
Show older comments
function v=f(t,x)
k=120000 ; %The stiffnes value of structure N/s
c=1000 ; %The damping value of structure kg/s
m=1000 ; %The total massa of structure kg
Fo=150;
w=5;
v=[x(2);x(2)*-(k/m) + x(2)*-(c/m) + Fo/m *cos(w*t)];% the equat?on of motion of the single degree
%of freedome under the harmonic load ( Fo.cos(wt)).
end
and ...
clc
clear
y0=[0,01 0,5]; %enter the initial conditions.
t0=[0 60] ; %enter the first and final time for the analysis.
[t,x]=ode45('f',t0,y0);
plot (t,x(:,1))%plot the results.
ERRORS:
Undefined function or variable 'v'.
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
0 Comments
Accepted Answer
Stephan
on 14 Apr 2020
clc
clear
y0=[0.01 0.5]; %enter the initial conditions.
t0=[0 60] ; %enter the first and final time for the analysis.
[t,x]=ode45(@f,t0,y0);
plot (t,x(:,1))%plot the results.
function v=f(t,x)
k=120000 ; %The stiffnes value of structure N/s
c=1000 ; %The damping value of structure kg/s
m=1000 ; %The total massa of structure kg
Fo=150;
w=5;
v=[x(2);x(2)*-(k/m) + x(2)*-(c/m) + Fo/m *cos(w*t)];% the equat?on of motion of the single degree
%of freedome under the harmonic load ( Fo.cos(wt)).
end
2 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!