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

 채택된 답변

Thorsten
Thorsten 2014년 12월 1일

0 개 추천

set = [0.4 0.204 0.242];
manoev = 1:5;
for i = 1:numel(set)
for j = 1:numel(manoev)
filename = ['Dataset_' num2str(set(i)) '_U_' int2str(manoev(j)) '.csv'];
Data(i, j) = csvread(filename);
end
end

댓글 수: 2

Andil  Aboubakari
Andil Aboubakari 2014년 12월 1일
it worked with the xlsread. Thanks
Akash kumar
Akash kumar 2022년 7월 2일
its work

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Sean de Wolski
Sean de Wolski 2014년 12월 1일

0 개 추천

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)
Andil  Aboubakari
Andil Aboubakari 2014년 12월 1일

0 개 추천

Thanks.
Is it possible to use the same syntax with the save function as well? After each five, all saved into one according to (0.4 0.204 and 0.242)

카테고리

도움말 센터File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

태그

질문:

2014년 12월 1일

댓글:

2022년 7월 2일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by