Error using fwrite Invalid file identifier. Use fopen to generate a valid file identifier.
Show older comments
Hello,
This matlab code reads a .raw file with a sequence of images and does small crops of the original one. After cropping, it saves them also in different .raw files with the name indicated.
I've checked the other sections of the program and they work perfectly; I get the correct small crops, but it fails to save them as .raw files.
for k=1:Ny
for i=1:Nx
filename = ['COMPT-EP2-Z40-U0-125x125x261-29298-', num2str(i), num2str(k),'.raw'];
fid=fopen(filename,'w+');
for j=1: length(CROP{1,1}(1,1,:))
fwrite(fid,CROP{k,i}(:,:,j));
end
fclose(fid);
end
end
And I get the following error:
Error using fwrite Invalid file identifier. Use fopen to generate a valid file identifier.
The value I get for fid after running the code is -1. I'm pretty sure the code worked three weeks ago.
What could be the problem??
Thank you very much.
Accepted Answer
More Answers (0)
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!