MATLAB Answers

Iam getting an error with the ODE45 function (line 90)and (line 115)?

1 view (last 30 days)
MAHMOUD NASSAR
MAHMOUD NASSAR on 14 Apr 2020
Commented: Stephan on 16 Apr 2020
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

Sign in to comment.

Accepted Answer

Stephan
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

MAHMOUD NASSAR
MAHMOUD NASSAR on 14 Apr 2020
thank u , but it still give me the same error
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);

Sign in to comment.

More Answers (0)

Products


Release

R2019a