What is the correct syntax for num2str
Show older comments
Hi guys,
I am having some problems with the num2str. I am trying to read/save/move file names like Dataset_0.4_u1 to u5.csv ,Dataset_0.204_u1 to u5.csv and Dataset_0.242_u1 to u5.csv.
I tried with file name or using the num2str and have all them into one single loop, if possible.
filename=('Dataset' (num2str(set)) 'U' (num2str(Manoev)) );
Dataset(num2str(set))U(num2str(Manoev))=[[Data(num2str(set))]{1,Manoev}]
'set' corresponds to 0.4,0.204 and 0.242, 'manoev' is just from 1 to 5.
Thanks Regards
Accepted Answer
More Answers (2)
Sean de Wolski
on 1 Dec 2014
First, set is a very important MATLAB function so I would advise against shadowing it with a variable.
You would need to concatenate your strings with [] or strcat:
v = [1.1 3]
filename = ['Dataset' num2str(v(1)) 'U' num2str(v(2)) '.csv']
Frankly through, I would just use sprintf instead of num2str:
filename = sprintf('Dataset%gU%g.csv',v)
1 Comment
Andil Aboubakari
on 1 Dec 2014
Andil Aboubakari
on 1 Dec 2014
0 votes
Categories
Find more on Debugging and Analysis 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!