how to give path of the input and output files in matlab?

i have a M file in FOLDER_1...in that i coded to process some files in FOLDER_2 and i need to store the output files in FOLDER_3..i given the path in M file. .below is my code...i am stuck here..help needed my current folder(where my .m file is) is: 'C:\Users\FOLDER_1\
path_01 = 'C:\Users\FOLDER_2\';
path_02 = 'C:\Users\FOLDER_3\';
mkdir(path_01,'FOLDER_3');
Filelist = dir(fullfile(path_01, '*.ascii'));
for i = 1:length(Filelist)
filename_out = fullfile(path_02, [Filelist(i).name]);
RD=load(Filelist(i).name);
GO=load('Chlis.txt');
nrec=size(RD,1);
nchl=size(GO,1);
for i = 1:nrec,
for j = 1:nchl,
RD(i,j)=RD(i,j)*GO(j,2)+GO(j,3);
end
end
dlmwrite(filename_out,RD,'delimiter', '\t', ...
'precision', '%.6f');
getting error as:
??? Error using ==> load
Unable to read file datafile.ascii: No
such file or directory.
Error in ==> ascii at 8 RD=load(Filelist(i).name);

7 comentarios

lvn
lvn el 6 de Mzo. de 2014
Editada: lvn el 6 de Mzo. de 2014
Can you remove the ; at the end of this line and tell us what it gives?
filename_out = fullfile(path_02, [Filelist(i).name])
same error
??? Error using ==> load
Unable to read file datafile.ascii: No
such file or directory.
Error in ==> ascii at 8 RD=load(Filelist(i).name);
sandy
sandy el 6 de Mzo. de 2014
Editada: sandy el 6 de Mzo. de 2014
my file to load is inside the path_01(datafile.ascii)..its not loading actually.. also note..if i place my input file in FOLDER_01,its working.but its not loading input file from FOLDER_2(in path_01...)any path of files to be changed..?
lvn
lvn el 6 de Mzo. de 2014
Yes but I meant, if you remove the ';' you will get additional output on the screen which can help in answering your question.
Have you checked whether Filelist(i).name is actually what you expect it is?
sandy
sandy el 6 de Mzo. de 2014
Editada: sandy el 6 de Mzo. de 2014
yes..Filelist(1)name is datafile.ascii...if you see the error.its identifying the file.but not loading by load() function at error line...code is running fine only if i keep M file and input file(datafile.ascii) in same folder location.but i split them in different folder..this error strikes..
lvn
lvn el 6 de Mzo. de 2014
Editada: lvn el 6 de Mzo. de 2014
Ah i see now,
RD=load(Filelist(i).name);
should probably be
RD=load(fullfile(path_01, [Filelist(i).name]));
and
filename_out = fullfile(path_02, [Filelist(i).name]);
should probably be
filename_out = fullfile(path_03, [Filelist(i).name]);
sandy
sandy el 6 de Mzo. de 2014
brilliant...it works ivn...thank you...

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Search Path en Centro de ayuda y File Exchange.

Preguntada:

el 6 de Mzo. de 2014

Comentada:

el 6 de Mzo. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by