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

1 visualización (últimos 30 días)
MUHAMMAD UBAID KHALID
MUHAMMAD UBAID KHALID el 24 de Abr. de 2023
Respondida: Alan Stevens el 24 de Abr. de 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))

Respuestas (1)

Alan Stevens
Alan Stevens el 24 de Abr. de 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--')

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by