error: Index exceeds matrix dimensions.

%This begins the force analysis
for turn=['a','b','c','d','e','f','g']
r.(turn).r3=.331;
r.(turn).force=r.(turn).force(:,2);
r.(turn).v=length(r.(turn).force);
r.(turn).justtime=r.(turn).justtime(1:r.(turn).v);
r.(turn).justangle=r.(turn).justangle(1:r.(turn).v);
r.(turn).sinangle=sin(r.(turn).justangle);
r.(turn).nettorque=(r.(turn).r3)*(r.(turn).sinangle).*(r.(turn).force);
for b=1:(r.(turn).v);
r.(turn).deltatorque(b)=r.(turn).nettorque(b+1)-r.(turn).nettorque(b);
end
r.(turn).deltatorque=r.(turn).deltatorque.';
r.(turn).network=(r.(turn).nettorque(1:r.(turn).v)).*(r.(turn).deltatheta(1:r.(turn).v));
r.(turn).deltapotential=(r.(turn).nettorque).*(r.(turn).justangle);
r.(turn).gravity=(9.81*(r.(turn).m))*(r.(turn).deltatheta);
r.(turn).withoutgravity=(r.(turn).deltapotential(1:r.(turn).v))-(r.(turn).gravity(1:r.(turn).v));
r.(turn).totalwork=sum(r.(turn).withoutgravity);
fprintf('The Total Work is %f\n',r.(turn).totalwork)
end

1 Commento

per isakson
per isakson il 26 Feb 2015
Modificato: per isakson il 26 Feb 2015
It's difficult to spot the cause of the error by inspection. The problem might even be with the input data rather than this code.

Risposte (0)

Questa domanda è chiusa.

Tag

Richiesto:

il 26 Feb 2015

Chiuso:

il 20 Ago 2021

Community Treasure Hunt

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

Start Hunting!

Translated by