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!

Answers (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 Comments

Thanks for the help!
Then please mark it as Answered if we're done. Thanks.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 9 Apr 2013

Community Treasure Hunt

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

Start Hunting!