Need a space in strcat comand
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MINATI PATRA
am 26 Dez. 2023
Kommentiert: Stephen23
am 26 Dez. 2023
V = [1 2 3 4 5];
strcat ('R = ', strjoin(string( V),', '))
I got the following answer while running the above code
"R =1, 2, 3, 4, 5"
But i need (a white space after '=' sign)
"R = 1, 2, 3, 4, 5"
1 Kommentar
Stephen23
am 26 Dez. 2023
The solution is already given in the STRCAT documentation:
V = 1:5;
strcat({'R = '},strjoin(string( V),', '))
Akzeptierte Antwort
Dyuman Joshi
am 26 Dez. 2023
V = [1 2 3 4 5];
out1 = strjoin(["R =" strjoin(string(V),', ')])
You can also add strings like this -
out2 = "R = " + strjoin(string(V),', ')
0 Kommentare
Weitere Antworten (1)
Image Analyst
am 26 Dez. 2023
V = [1 2 3 4 5];
str = sprintf('R = %s', strjoin(string( V),', '))
0 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!