Struct contents reference from a non-struct array object. Error
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hello, my friends and I are writing this script for our Accelerometer Lab. Both of my partners are able to run this section of script just fine but on my MatLab it will not work for some reason even though we all have the same files. The "Struct contents reference from a non-struct array object." error appears on the line the defines "time." Could somebody offer some insight for why this maybe happening? Below is the code and the file that is trying to be accessed.
clc
clear
close all
filename = 'Accel2.CSV'; %Plot Bouy accelerometer data
data = importdata(filename);
Fs= 100;
*time = 100*(data.data(:,1)*1/Fs);*
acc_z = data.data(:,4)-1014.4;
figure
plot(time,acc_z)
title('Frequency Vs. Time of Bouy Accelerometer Data')
xlabel('Time (s)')
ylabel('Z Axis Acceleration (m/s^2)')
figure
plot(acc_z)
title('Frequency Vs. Index of Bouy Accelerometer Data')
xlabel('Index')
ylabel('Z Axis Acceleration (m/s^2)')
댓글 수: 0
답변 (1개)
Star Strider
2018년 3월 25일
Your file has 18 header lines, and every other row of the original ‘data’ matrix are NaN(1:4).
Try this:
Data = importdata('Accel2.csv', ',', 18);
data = Data.data;
data = data(all(~isnan(data),2),:);
Fs= 100;
time = 100*data(:,1)/Fs;
acc_z = data(:,4)-1014.4;
figure
plot(time,acc_z)
title('Frequency Vs. Time of Bouy Accelerometer Data')
xlabel('Time (s)')
ylabel('Z Axis Acceleration (m/s^2)')
figure
plot(acc_z)
title('Frequency Vs. Index of Bouy Accelerometer Data')
xlabel('Index')
ylabel('Z Axis Acceleration (m/s^2)')
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!