Write loop for read then write multiple files
Ältere Kommentare anzeigen
Hi!
I've wrote a script for read a binary float32 file, then write it into a txt file. I works for one file, but i have several binary files. The file names are 001001.bin,001002.bin...etc.
Here is the original loop:
fname='D:\001001.bin';
fid = fopen(fname);
data = fread(fid,'float32');
dlmwrite('001001.bin.txt',data,'precision','%10.5f','newline','pc')
I tried to make a loop, but it has an error message: "In an assignment A(:) = B, the number of elements in A and B must be the same."
Here is the loop:
v=dir('*.bin')
for i=1001:v
fname(i)='D:\00(i).bin';
fid(i) = fopen(fname(i));
data(i) = fread(fid(i),'float32');
dlmwrite('00(i).bin.txt',data(i),'precision','%10.5f','newline','pc')
end
Thanks for helping!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!