필터 지우기
필터 지우기

How to use sprintf when the parameter contains an array cell

조회 수: 2 (최근 30일)
Elahe Karimi
Elahe Karimi 2019년 4월 25일
댓글: Elahe Karimi 2019년 4월 25일
Hi,
How to use sprintf when the Address parameter contains an array cell?
Address={'./DataBase/1/(%d).png','./DataBase/2/ (%d).png' , './DataBase/3/(%d).png','...........','./DataBase/10/(%d).png'}
for j=1:10
Address=Address(j);
end
S{i}=sprintf(Address,i);
.
.
.
When I use this code, I get the following error :
Error using sprintf
Invalid format.Error in LoadData (line 29)
S{i}=sprintf(Address,i);
thank you
  댓글 수: 3
Stephen23
Stephen23 2019년 4월 25일
Writing out all of those format strings in the cell array is a waste of time anyway: it is better to generate them in the loop, exactly as madhan ravi showed.
Elahe Karimi
Elahe Karimi 2019년 4월 25일
Thanks for the suggestions. I did it and the code does not make a mistake. Thank you so much for answering my question.

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

채택된 답변

madhan ravi
madhan ravi 2019년 4월 25일
n=10;
S=cell(n,1);
for k = 1:n
S{k}=sprintf('./DataBase/%d/(%d).png',[k;k]);
... some operation
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by