I need some help with creating a program containing a graph and table!

I thought that what I have below would be enough to complete a program. I needed to calculate the weight and torque, then create a table with angle, mass, weight, and torque. I also needed to create a mass vs angle graph. What am I doing wrong?
A=[0;15;25;39;54;70;105;115;128;147;167]; % Given angles in degrees.
m=[200;250;300;350;400;450;500;550;600;650;700]; % Given mass in grams.
plot(A',m','-kd'); % Plot m vs A using solid black line with diamond markers.
g=9.81; % Acceleration due to gravity.
r=6.0325; % Given radius of test wheel in centimeters.
W=m.*g; % Formula used to calculate the Weight (W).
T=W.*r; % Formula used to calculate the Torque (T).
Table[A',m',W',T']; % Combines angles, mass, weight, and torque values into rows.
fprintf('\n'); % Print one blank line.
disp(' Angle,A Mass,m Weight,W Torque,T') % Print table headings.
fprintf('%9.2f deg10.3f g%8.1f kg%6.2f N/cm \n', Table') % Format, print Table content.

4 Comments

Did you forget an assignment in Table[A',m',W',T'];
Table = [A',m',W',T'];
I've made the correction recommended by Walter but still nothing.
Try
Table = [A(:) ,m(:), W(:), T(:)];
I'm able to get them to create columns for each after running this command in the command window. Now I have to get this to work with my program above.

Sign in to comment.

 Accepted Answer

You missed a '%'
fprintf('%9.2f deg%10.3f g%8.1f kg%6.2f N/cm \n', Table')
The '%' after 'deg' is missing in your code.

6 Comments

Thanks. But there must be something that I'm missing?!?
This is what I'm getting:
Angle,A Mass,m Weight,W Torque,T
0 200.0000 1.9620 11.8358
15.0000 250.0000 2.4525 14.7947
25.0000 300.0000 2.9430 17.7536
39.0000 350.0000 3.4335 20.7126
54.0000 400.0000 3.9240 23.6715
70.0000 450.0000 4.4145 26.6305
105.0000 500.0000 4.9050 29.5894
115.0000 550.0000 5.3955 32.5484
128.0000 600.0000 5.8860 35.5073
147.0000 650.0000 6.3765 38.4662
167.0000 700.0000 6.8670 41.4252
0 deg 200 g 1.962 kg 11.84 N/cm
15 deg 250 g 2.453 kg 14.79 N/cm
25 deg 300 g 2.943 kg 17.75 N/cm
39 deg 350 g 3.434 kg 20.71 N/cm
54 deg 400 g 3.924 kg 23.67 N/cm
70 deg 450 g 4.415 kg 26.63 N/cm
105 deg 500 g 4.905 kg 29.59 N/cm
115 deg 550 g 5.396 kg 32.55 N/cm
128 deg 600 g 5.886 kg 35.51 N/cm
147 deg 650 g 6.377 kg 38.47 N/cm
167 deg 700 g 6.867 kg 41.43 N/cm
I was able to get the program to run but I don' t need the "top" set of data.
Sorry, the ones without the units.
Great! Thank you very much Mr. Roberson.

Sign in to comment.

More Answers (0)

Categories

Find more on App Building 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!