Function in for loop

11 vues (au cours des 30 derniers jours)
Tamas Brigancz
Tamas Brigancz le 11 Fév 2016
Commenté : Tamas Brigancz le 11 Fév 2016
Hi I need to read data from .wfm files. Each file has 25 frames from the oscilloscope and I need the y and t data. The filenames are tdpo001_ch1.wfm ... tdpo150_ch1.wfm and I have no idea how to make the middle of the filename as the variable for a for loop. Thanks for the answer in advance!

Réponse acceptée

Guillaume
Guillaume le 11 Fév 2016
Modifié(e) : Guillaume le 11 Fév 2016
Use sprintf:
for fileidx = 1:150
filename = sprintf('tdpo%03d_ch1.wfm', fileidx)
%... use filename
end
The '%03d' in format string means replace with the string representation of fileidx as integer, padding with zero to a size of 3 characters.
  1 commentaire
Tamas Brigancz
Tamas Brigancz le 11 Fév 2016
I got it now, thank you!!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by