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

1 vue (au cours des 30 derniers jours)
MUHAMMAD UBAID KHALID
MUHAMMAD UBAID KHALID le 24 Avr 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))

Réponses (1)

Alan Stevens
Alan Stevens le 24 Avr 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--')

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by