Convert double type string to data type
Mostra commenti meno recenti
%These commands generate the random integers described in the problem statement. %Do not overwrite the values of X and Y in your own code. X = randi([1 10]); Y = randi([1 10]); %Enter the commands for your script mfile here. XandY = ([X, Y]) XplusY = ([X + Y])
1 Commento
dpb
il 8 Nov 2020
The question is totally unclear as to what you are trying to do/ask...give example of what you would want a result to be and for what purpose.
Risposta accettata
Più risposte (2)
Mathieu NOE
il 9 Nov 2020
hi
simply use the string() command like :
>> X = pi
X =
3.1416
>> str = string(X)
str =
"3.1416"
1 Commento
I W
il 9 Nov 2020
Mathieu NOE
il 9 Nov 2020
so this is simple string concatenation and then disp (for display in command window:
X = pi
Y = 2.234
disp(['The value of X is ' num2str(X) ' and the value of Y is ' num2str(Y) ' bla bla'])
gives
The value of X is 3.1416 and the value of Y is 2.234 bla bla
3 Commenti
I W
il 9 Nov 2020
Mathieu NOE
il 9 Nov 2020
XandY = X +Y;
disp(['The value of X and Y is ' num2str(XandY)])
% you can also use sprintf
% see help sprintf
I W
il 9 Nov 2020
Categorie
Scopri di più su Characters and Strings 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!