0

I have this for loop

for mass = 1:.1:4
theta = 60;
Fw = [0 -9.8*mass 0];
Rw = [ 0.2*cosd(theta) 0.2*sind(theta) 0];
Mw = cross(Rw,Fw);
Fjrf = [30 50 0];
Rjrf = [0.4*cosd(theta) 0.4*sind(theta) 0];
Mjrf = cross(Rjrf,Fjrf);
alpha = 5;
Ialpha = [0 0 alpha*(0.02+mass*0.2^2)];
Ms = Ialpha - Mjrf - Mw;
omega = [0 0 pi];
alphav = [0 0 5];
anorm = ([-cosd(theta) -sind(theta) 0]*(norm(omega))^2);
atang = cross(Rjrf,alphav);
a = anorm + atang;
Fmuscle = norm(mass*a - Fjrf - Fw)
mass
plot(mass,Fmuscle)'
hold on
end

Where in the end the output is just various values of Fmuscle, that correspond to values of mass varrying from 1 to 4 at intervals of .1. I am trying to plot all these values on a graph (mass =x and Fmuscle = y) but I cannot figure out how to generate this. With the code I have above I simply get an empty graph, even though I get all the right variables. Thanks!

1 Answer 1

0

This what you want?

i = 0;  %set initial index
clear x y;  %clear these variables
for mass = 1:.1:4
  i = i + 1;  %increment index
  theta = 60;
  Fw = [0 -9.8*mass 0];
  Rw = [ 0.2*cosd(theta) 0.2*sind(theta) 0];
  Mw = cross(Rw,Fw);
  Fjrf = [30 50 0];
  Rjrf = [0.4*cosd(theta) 0.4*sind(theta) 0];
  Mjrf = cross(Rjrf,Fjrf);
  alpha = 5;
  Ialpha = [0 0 alpha*(0.02+mass*0.2^2)];
  Ms = Ialpha - Mjrf - Mw;
  omega = [0 0 pi];
  alphav = [0 0 5];
  anorm = ([-cosd(theta) -sind(theta) 0]*(norm(omega))^2);
  atang = cross(Rjrf,alphav);
  a = anorm + atang;
  Fmuscle = norm(mass*a - Fjrf - Fw);
  x(i) = mass;    % set the appropriate row of x vector
  y(i) = Fmuscle; % same for y
end
plot(x, y);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.