How to add an input to the end of an fprintf function
1 view (last 30 days)
Show older comments
units = input('Please enter the units for your rectangular coordinates: ','s');
I have this line of code right here. I would like the user to enter the units, and then have them display after this line of code below:
fprintf('Our rectangular coordinates converted to cylindrical coordinates are (%0.2f,%0.2f,%0.2f)' , r, lambda, phi )
For example, if the units are in mm, I just need the code to read: (r , lambda, phi) mm
I tried using this code below, but it was unsuccessful.
fprintf('Our rectangular coordinates converted to cylindrical coordinates are (%0.2f,%0.2f,%0.2f)' , r, lambda, phi ) + units
0 Comments
Accepted Answer
Star Strider
on 3 Feb 2024
Perhaps this —
r = rand;
lambda = rand;
phi = rand;
units = 'mm';
fprintf('Our rectangular coordinates converted to cylindrical coordinates are (%0.2f,%0.2f,%0.2f) %s' , r, lambda, phi, units)
.
2 Comments
More Answers (0)
See Also
Categories
Find more on NaNs 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!