Please help me with code for the below ode

enq of motion.jpg

6 件のコメント

Alex Mcaulley
Alex Mcaulley 2019 年 8 月 26 日
What have you tried so far?
Torsten
Torsten 2019 年 8 月 26 日
Where is the ode for y ?
Karthik K
Karthik K 2019 年 8 月 26 日
this is the function file
function f = forced_coulomb_base(t,x,y)
mu=0.30;
wn = 150;
xx = 10;
yy = 5;
%m=100;
f=zeros(2,1);
f(1) = x(2) - y(2) ;
f(2)= -mu*9.81*sign(x(2)-y(2)) - (wn^2)*(xx-yy)*x(1) ;
end
this is my script file
clc
clear all
tspan=0:0.1:20;
x0 = [0.3;0];
y0 = [0.25;0];
[t,x,y]=ode45(@forced_coulomb_base,tspan,x0,y0);
disp (' t x(t) xd(t)')
disp ([t x y]);
plot(t,x(:,1));
hold on
plot (t, x(:, 2),'r');
grid on
xlabel('t');
ylabel('x(t), xdot(t)');
These are the errors
Error using forced_coulomb_base (line 11)
Not enough input arguments.
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in free_base (line 9)
[t,x,y]=ode45(@forced_coulomb_base,tspan,x0,y0);
>>
darova
darova 2019 年 8 月 26 日
Can you please attach your equations?
Why are you using constants for xx and yy?
1Untitled.png
Karthik K
Karthik K 2019 年 8 月 27 日
This is a base excitation probem in vibration
equation_of_motion.jpg
Walter Roberson
Walter Roberson 2019 年 8 月 27 日
You have
function f = forced_coulomb_base(t,x,y)
so forced_coulomb_base expects to be passed three variables.
You have
[t,x,y]=ode45(@forced_coulomb_base,tspan,x0,y0);
ode45 passes two parameters to the function: the independent variable in the first parameter, and the boundary conditions in the second parameter.
You cannot calculate two separate ode by passing them as additional parameters and expecting additional outputs: all boundary conditions must be passed in a single variable, and all calculations must be returned in a single variable.

サインインしてコメントする。

回答 (0 件)

カテゴリ

質問済み:

2019 年 8 月 26 日

コメント済み:

2019 年 8 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by