Struct contents reference from a non-struct array object.
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I have re-sampled data at different frequencies and now want to filter those new data sets. I have managed to do it as one structure (c_accData) but I need it to an ODBA for each frequency(Fs) which currently it isn't. To do this I then used c_rate instead of c_accData. c_rate = Fs(j) so stands for the current frequency. When I try and run this I get an error "struct content reference from a non-struct array object". I am assuming this is because c_rate isn't a non-struct array object but I'm not entirely sure how to go about this. Would love any feedback and help you guys have.
%% Filter the data
% [MD comment]: Note that you will have to change these filter settings for
% the very low sample rates (1Hz, 10Hz) because you can't filter with stop/pass
% frequencies above the sample frequency.
for j = 1:length(Fs)
c_rate = Fs(j)
%Check if re-sampled filtered files exist
if ~exist([filename(1:end-4) '_resample_filt_' num2str(c_rate) 'hz.mat'],'file')
% Run a bandpass filter
% Run the same filter specifications (above) for the each axis
stopBand = [0.001 10];
passBand = [0.5 5];
filtMode = 3;
%Create empty startTimes and endTimes arrays to check data alignment.
startTimes = [];
endTimes = [];
%if they don't exist, filter and create it
[X_filt] = ButterFilt(c_rate.x, stopBand, passBand, c_rate.sampleRate,filtMode);
[Y_filt] = ButterFilt(c_rate.y, stopBand, passBand, c_rate.sampleRate,filtMode);
[Z_filt] = ButterFilt(c_rate.z, stopBand, passBand, c_rate.sampleRate,filtMode);
% Calcualte Overall Dynamic Body Acceleration
ODBA = sqrt(X_filt.^2 + Y_filt.^2 + Z_filt.^2);
% [MD comment]: I suggest you avoid overwriting the raw data with the
% filter data, so you can compare the two and check that you are happy
% with the filter settings.
c_rate.x = X_filt;
c_rate.y = Y_filt;
c_rate.z = Z_filt;
c_rate.OBDA = ODBA;
c_rate.startTime = c_rate.timeStamp(1);
c_rate.endTime = c_rate.timeStamp(end);
startTimes = [startTimes c_rate.timeStamp(1)]; %#ok<*AGROW>
endTimes = [endTimes c_rate.timeStamp(end)];
% Save filtered data to a Mat file
save([filename(1:end-4) '_resample_filt_' num2str(c_rate) 'hz.mat']);
else
load ([filename(1:end-4) '_resample_filt_' num2str(c_rate) 'hz.mat']);
end
end
% % Clear unnecessary vectors
% clear X_filt Y_filt Z_filt
7 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Applications finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!