How to put in Multiple Inputs and Display Result in a Table
Show older comments
Ok, so I have a problem where I have to write a program to find the force of a spring attached to a pulley with changing values of theta. I was able to write the program, so that it asks for the input theta and it calculates the weight/force. I now need to be able put in multiple inputs (10: 0-90 degrees in increments of 10 degrees). What is the process to do this, I am completely lost and have no idea how to do this. I have tried entering my input as a matrix, but I get an error. I also have to have the results be displayed in a table. Also lost on this subject. Thank you so much for any help.
Here is the code I have written thus far:
a=20
R=10;
k=5;
t=input('Enter Theta: ');
l=(sqrt((R*(sind(t)))^2+a^2));
x=(l-a);
S=k*x;
p=atand(a/(R*sind(t)));
F=S*cosd(p);
fprintf(' The weight to keep this at equilibrium is %.4f lbs \n',F);
1 Comment
dpb
on 10 Oct 2013
If it's to get input from user, probably easiest to ask for start, end and increment and then compute the vector from those. You could set some default values first to allow user to select them as shortcut.
doc inputdlg
may be of interest
Accepted Answer
More Answers (0)
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!