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

2 ビュー (過去 30 日間)
Aaron
Aaron 2012 年 6 月 21 日
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 件のコメント
Walter Roberson
Walter Roberson 2012 年 6 月 21 日
Try
Table = [A(:) ,m(:), W(:), T(:)];
Aaron
Aaron 2012 年 6 月 21 日
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.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 21 日
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 件のコメント
Walter Roberson
Walter Roberson 2012 年 6 月 21 日
Comment out your disp()
Aaron
Aaron 2012 年 6 月 21 日
Great! Thank you very much Mr. Roberson.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by