How to repeat input prompt for each data set?

20 views (last 30 days)
I am trying to find resultant force through inputs of magnitude and direction, I am first required to input how many data sets 1-10. I can get my program to repeat but whatever is the last input for both my magnitude and direction just overwrites the other inputs I had just put in for them. How do I make it so that each inut pair of magnitude and direction can be used to find their own corresponding resultant force?
4条评论

Sign in to comment.

Accepted Answer

阿杰·库马尔(Ajay Kumar)
You are replacing the m and a everytime in the for loop. try this
u=menu('What is your unit system?','SI',“在glish');
d=input(“在ter Number of Data Sets 1-10');
尽管D <1 || D> 10
disp('Error')
d=input(“在ter Number of Data Sets 1-10');
end
n = [1:1:d];
forc=1:d
m(c)=input(“在ter Magnitude of Force:');
尽管m(c)<0||m(c)==0
disp('Error')
m(c)=input(“在ter Magnitude of Force:');
end
a(c)=input(“在ter Angle of Force:');
尽管a(c)<0||a(c)>360||a(c)==360
disp('Error')
一个=输入(“在ter Angle of Force:');
end
end
Now you can use datasets of m and a to calculate total resultant force.

More Answers (0)

Community Treasure Hunt

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

开始狩猎!