Using dir() in a compiled script
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Benjamin
el 12 de Sept. de 2014
Comentada: Benjamin
el 12 de Sept. de 2014
Hi everybody!
I'm trying to compile my matlab script which includes the dir function to get the files from a certain path. It works perfectly in the uncompiled *.m version but as soon as I've compiled my code as a console application it seems like that function doesn't work Here's the code:
...
path=strcat(path,'Results');
path2=strcat(path2,'\\Results');
fprintf('%s \n',path);
fprintf('%s \n', path2);
%Open file
fprintf('read files \n');
files=dir(strcat(path,'/*.txt'));
fprintf('list files \n');
fprintf(files.name);
fprintf('listed files \n');
k=1;
for i=1:length(files)
fprintf('i = %d \n',i);
filename=files(i).name;
if length(filename)>5
if strcmp(filename(1:6),'Blende')
fprintf('%s \n', filename);
filepath{k}=strcat(path2,'\\',filename);
k=k+1;
end
end
end
...
And this is the output:
Z:\...\Results
Z:\\...\\Results
read files
list files
??? Error using ==> fprintf
Not enough input arguments.
Error in ==> start at 52
MATLAB:minrhs
Z:\...\Programm>
I get the variable "path" which contains my path to the folder with my textfiles (it's on a server) over a function before. This seems to work since it prints that path.
Any idea?
Thanks!
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre File Operations 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!