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 ?
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
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