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 次查看(过去 30 天)
%%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

回答(1 个)

Jan
Jan 2015-2-2
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.
  1 个评论
Bruno
Bruno 2015-2-2
Simon:
Thanks for getting back to me so quickly.
I want store the filter file. “dbstop if error” indicate the “save (save_data,'Filter', '-ASCII')” as an error. Filename is too long.
Is there any way to get around this problem? Thanks Bruno

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by