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
댓글 수: 0
답변 (1개)
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!