Struct contents reference from a non-struct array object. Error
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
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)')
Antworten (1)
Star Strider
am 25 Mär. 2018
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)')
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!