Clear Filters
Clear Filters

2DOF question and other things...help me...

1 view (last 30 days)
alsgud qor
alsgud qor on 16 Apr 2020
Commented: Ameer Hamza on 19 Apr 2020
  2 Comments
alsgud qor
alsgud qor on 19 Apr 2020
Edited: alsgud qor on 19 Apr 2020
sorry this is what i ve done. I dunno how to put X, Y simultaneously...and there is error that
'HW5'function isn't defined like this...
======================================
function Homework5 =HW5(t,X)
m=10;
c=1000;
k=100000;
e=0.001;
w=100;
R=0.5;
X=R*cos(w*t);
Y=R*sin(w*t);
F1=m*e*w^2*cos(w*t);
F2=m*e*w^2*sin(w*t);
Homework5=[X(2); -c/m*X(2)-k/m*X(1)+F1/m];
==========================================
t=0:0.1:20;
>> X0=[0,0];
>> [t,X]=ode45(@HW5,t,X0);
and the error was 'Index exceeds array boundaries'

Sign in to comment.

Answers (1)

Ameer Hamza
Ameer Hamza on 19 Apr 2020
Since you haven't posted the equation in mathematical form, so I can only guess. The following code will not give any error, but I am not sure if it is what you want?
t=0:0.1:20;
X0=[0,0];
[t,X]=ode45(@HW5,t,X0);
function Homework5 =HW5(t, X)
m=10;
c=1000;
k=100000;
e=0.001;
w=100;
R=0.5;
F1=m*e*w^2*cos(w*t);
Homework5=[X(2); -c/m*X(2)-k/m*X(1)+F1/m];
end
  4 Comments
alsgud qor
alsgud qor on 19 Apr 2020
mx''+cx'+kx=mew^2coswt
my''+cy'+ky=mew^2sinwt
and this is my current progress...plz check this is right or not...
=============================
function Xdot =HW5(t,X)
m=10;
c=1000;
k=100000;
e=0.001;
w_rpm = 100; % 100, 1000, 2000
w=w_rpm*2*pi/60;
Fh=m*e*w^2*cos(w*t); % horizontal
Fv=m*e*w^2*sin(w*t); % vertical
% m x'' + c x' + k x = Fh (horizontal)
% x'' = -c/m x' -k/m x + Fh/m
% x1' = x2
% x2' = -c/m x2 -k/m x1 + Fh/m
% m y'' + c y' + k y = Fv (vertical)
% y'' = -c/m y' -k/m y + Fh/m
% y1' = y2
% y2' = -c/m y2 -k/m y1 + Fh/m
% X = [x1 ; x2 ; y1 ; y2]
Xdot=[X(2);
-c/m*X(2)-k/m*X(1)+Fh/m;
X(4);
-c/m*X(4)-k/m*X(3)+Fv/m];
end
======================
figure, plot(X(:,1)*1e3,X(:,3)*1e3)
grid on
xlabel('x, mm')
ylabel('y, mm')
pbaspect([1 1 1])
legend('2000 rpm')
Ameer Hamza
Ameer Hamza on 19 Apr 2020
Considering the ODEs you wrote, the function appears to be correct. However, the ODEs seems to be independent of each other? One would expect that for such a system, the system of ODEs should be coupled.

Sign in to comment.

Categories

Find more on Programming 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!