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

1 Ansicht (letzte 30 Tage)
MUHAMMAD UBAID KHALID
MUHAMMAD UBAID KHALID am 24 Apr. 2023
Beantwortet: Alan Stevens am 24 Apr. 2023
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))

Antworten (1)

Alan Stevens
Alan Stevens am 24 Apr. 2023
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--')

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by