How to use sprintf when the parameter contains an array cell
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Elahe Karimi
le 25 Avr 2019
Commenté : Elahe Karimi
le 25 Avr 2019
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 commentaires
Stephen23
le 25 Avr 2019
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.
Réponse acceptée
madhan ravi
le 25 Avr 2019
n=10;
S=cell(n,1);
for k = 1:n
S{k}=sprintf('./DataBase/%d/(%d).png',[k;k]);
... some operation
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!