how to plot column vs column from csv file using readmatrix?
36 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
SimTec
am 23 Jun. 2021
Kommentiert: Walter Roberson
am 23 Jun. 2021
I have a csv file that is named data,that contains 03 columns: clock,volt_a and volt_b:
array=readmatrix('data.csv');
plot(array)
when I readmatrix the csv file, it shows the data without its column's name.
0 Kommentare
Akzeptierte Antwort
KSSV
am 23 Jun. 2021
Bearbeitet: KSSV
am 23 Jun. 2021
You need to specify the column which you want. Read about MATLAB indexing.
array=readmatrix('data.csv');
plot(array(:,1),array(:,2),'r',array(:,1),array(:,3),'b')
legend('col2','col3')
OR
array=readmatrix('data.csv');
plot(array(:,1),array(:,2),'r')
hold on
plot(array(:,1),array(:,3),'b')
legend('col2','col3')
3 Kommentare
Walter Roberson
am 23 Jun. 2021
array=readmatrix('data.csv');
plot(array(:,1),array(:,2:3))
legend('col2','col3')
would not allow you to choose line colors without a slight bit further work, but is often good enough.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets 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!