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 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%%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 commentaires
Réponses (1)
Jan
le 2 Fév 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.
Voir également
Catégories
En savoir plus sur Search Path dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!