How can I plot specific columns of my csv file

18 views (last 30 days)
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?

Accepted Answer

dpb
dpb on 23 Apr 2017
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...
  3 Comments
dpb
dpb on 23 Apr 2017
Show your code; I had downloaded your file and the above ran with no errors when posted above to be sure wasn't something funky. Include all the error text in context.
Nikhil Maganti
Nikhil Maganti on 23 Apr 2017
I used audioread instead of csvread by mistake.But I have tried your code.It works.Thank you.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import and Export in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!