Dear All: I made a filter script. I cannot save the output of my sequential file as dat files in folder. The error message is “error using save. Filename is too long”. Please, could someone indicate me the problem? Thanks Bruno
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
%%Loadfile data directory_name=uigetdir(pwd,'Select data directory');
directory_name=([directory_name '\']);
% directory_save=uigetdir(pwd,'Select save directory');
% directory_save=([directory_save '\']);
disp(directory_name)
mkdir(directory_name,'FilterHere');
directory_save=([directory_name,'FilterHere\']);
files=dir([directory_name,'*.dat']);
if isempty(files) msgbox('No raw files in this directory'); end counter = 0;
for i_files=1:length(files);
filename=files(i_files).name;
[path,filename,ext] = fileparts(filename);
file = fullfile(directory_name,[filename,'.dat']);
counter = counter + 1;
disp([filename,'(',num2str(i_files),'of', num2str(length(files)), ')'])
i_u=(strfind(filename,'_'))-1;
numbers=dlmread(file);
data=numbers(:,1);
end
FileNum=1:i_files;
for filtLow = 10;
filtHigh = 500;
Fs = 2000;
[b, a] = butter(1, [filtLow/(Fs/2), filtHigh/(Fs/2)]);
Filter = (filtfilt(b, a,data))';
dimstr=num2str(Filter);
save_data=fullfile(directory_save,[filename,'_',dimstr,'dat']);
save(save_data,'Filter', '-ASCII');
end
0 comentarios
Respuestas (1)
Jan
el 2 de Feb. de 2015
Filter is the output of the filtered data:
Filter = (filtfilt(b, a,data))';
I guess, that this is a large vector. Then you convert it to a string, which is most likely huge:
dimstr = num2str(Filter);
Finally dimstr is used as name of the variable. But most likely you want to store the filtered data in the file, not in its file name.
The debugger would reveal such problems immediately:
dbstop if error
Then Matlab stops, when the error occurs and you can check the values of the locally used variables.
Ver también
Categorías
Más información sobre Whos 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!