Beginning Matlab simple text question
Show older comments
I am using a textbox that will display updating information on a simple force calculator and I need to know what to add to this code to display the units at the end of the string (Newtons in this case). Thank you!
set(h,'string',num2str(ForceB)); %will display Force in Newtons
Accepted Answer
More Answers (1)
Image Analyst
on 5 May 2014
Try this:
% Create a string from the number, and append the word Newtons.
str = sprintf('%.3f Newtons', ForceB);
% Send the string to the static text label control.
set(h,'String',str); % Will display Force in Newtons
Categories
Find more on Scope Variables and Generate Names 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!