필터 지우기
필터 지우기

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

조회 수: 2 (최근 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에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by