Matlab Function not displaying all the answer

Hey, I'm having trouble with a function. I'm required to calculate (using a function) the displacement (da), the veloctiy (va) and the accleration (aa) of a system. What I can't get the function to do is display all 3 of these answers when I run the function. The only answer that is shown after running the function is the displacement. My first line of coding is [da, va, aa] = myfinda (theta_rad) The rest of the code is the equations to work out the 3 values. Thanks!

回答 (1 件)

Image Analyst
Image Analyst 2013 年 4 月 9 日

1 投票

Either leave off the semicolon when you compute it, or use fprintf(). Below I do it both ways:
da = 1.2345
va = 2.345676789
aa = pi*42
fprintf('Displacement = %.3f.\nVelocity = %.3f.\nAcceleration = %.5f.\n',...
da, va, aa);
In the command window:
da =
1.2345
va =
2.3457
aa =
131.9469
Displacement = 1.234.
Velocity = 2.346.
Acceleration = 131.94689.

2 件のコメント

Simon Moseley
Simon Moseley 2013 年 4 月 9 日
Thanks for the help!
Image Analyst
Image Analyst 2013 年 4 月 9 日
Then please mark it as Answered if we're done. Thanks.

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

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2013 年 4 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by