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

1 次查看(过去 30 天)
  2 个评论
alsgud qor
alsgud qor 2020-4-19
编辑:alsgud qor 2020-4-19
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'

请先登录,再进行评论。

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-4-19
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 个评论
alsgud qor
alsgud qor 2020-4-19
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 2020-4-19
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by