how to write file in userdefined directors using fopen/fwrite/fclose
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I want to write file in user defined folder but not in matlab current directory. I tried to use following commands but no success, still writing into current matlab directory
P1=path;
path(P1,'C:\MATLAB701\work\user_defined');
files_out = dir(fullfile(matlabroot,'\work\user_defined/*.dat'));
filename = files_out(1).name;
outid = fopen(filename,'w+');
fwrite(outid,imagedata,'uint16');
fclose(outid);
Any help will be appreciable. Thanks, Rami
0 comentarios
Respuesta aceptada
Jan
el 23 de Mzo. de 2012
The dir command replies the file names without the path.
There is no need to add the folder to the path. Better:
folder = fullfile(matlabroot, '\work\user_defined\');
files_out = dir(fullfile(folder, '*.dat'));
filename = files_out(1).name;
disp(filename); % Show the filename
outid = fopen(fullfile(folder, filename), 'w+');
fwrite(outid,imagedata,'uint16');
fclose(outid);
A general method to investigate such problems is the debugger. Set a break point inthe editor to the line, which behaves unexpectedly. Then Matlab stops at this break point and you can check the values of the variables in the command window.
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!