MATLAB: How to plot specific columns of the csv file

csvread

I have attached the csv file of my gcode obtained from the magnetic data from the 3D printer.I want to plot the X_value column against time values.Can someone walk me through this?

Best Answer

data=csvread('1333_mag.csv',1,0); % read the csv file, skip header row
plot(data(:,1),data(:,2) % plot 2nd column vs 1st
xlabel('time')
ylabel('X')
Slightly more exotic
data=readtable('1333_mag.csv'); % read again, this time as table object/class...
data.Properties
ans =
Description: ''
VariableDescriptions: {}
VariableUnits: {}
DimensionNames: {'Row' 'Variable'}
UserData: []
RowNames: {}
VariableNames: {'time' 'X_value' 'Y_value' 'Z_value'}
plot(data.time,data.X_value)
xlabel(data.Properties.VariableNames(1))
ylabel('X')
Any number of other choices as well...