how to get value from work space
Mostra commenti meno recenti
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 Commento
Risposte (2)
KSSV
il 6 Gen 2017
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
Categorie
Scopri di più su Title in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!