This code give me an error of Index exceeds array bounds.

1 次查看(过去 30 天)
clc
clear all
close all
m=60;
g=9.81;
k=80;
m_2=10;
m_1=15;
h=100;
w=15;
t=1:100:10;
for i=1:t
x(i)=((m*g)/k)+((m_2*(g*h)^1/2)*sin(w*t)/(w(m_1+m_2)))-((m*g)*cos(w*t)/k)
end
plot(t,x(i))

回答(1 个)

Alan Stevens
Alan Stevens 2023-4-24
More like this?
m=60;
g=9.81;
k=80;
m_2=10;
m_1=15;
h=100;
w=15;
t=1:10:100;
x = zeros(1,numel(t));
for i=1:numel(t)
x(i)=((m*g)/k)+((m_2*(g*h)^1/2)*sin(w*t(i))/(w*(m_1+m_2)))-((m*g)*cos(w*t(i))/k);
end
plot(t,x,'o--')

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by