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
2013-4-9
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
2013-4-9
Image Analyst
2013-4-9
Then please mark it as Answered if we're done. Thanks.
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!