how to get value from work space
显示 更早的评论
hello I am working on project . for exmaple i have this code
clc;
clear all;
a=input('enter a:');
title=(' the value of a is :');
I want the title to show the value of the variable a that I insert. how to do it ?
1 个评论
回答(2 个)
KSSV
2017-1-6
clc;
clear all;
a=input('enter a:');
title = sprintf('The value of a is:%f',a)
It is highly recommended to use the non-evaluating syntax of input, which is faster and much more secure:
>> str = input('input value a: ','s');
input value a: 5.6
>> val = str2double(str)
val = 5.6000
And put it into your title using either of these:
>> txt = sprintf('the value of a is %s',str)
txt = the value of a is 5.6
>> txt = sprintf('the value of a is %s',num2str(val))
txt = the value of a is 5.6
类别
在 帮助中心 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!