how to plot column vs column from csv file using readmatrix?

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.

 採用された回答

KSSV
KSSV 2021 年 6 月 23 日
編集済み: KSSV 2021 年 6 月 23 日

1 投票

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 件のコメント

SimTec
SimTec 2021 年 6 月 23 日
Thank you, i did not see this detail on the help page of readmatrix or I did not look for ir?
KSSV
KSSV 2021 年 6 月 23 日
You need to know read about plot.
Walter Roberson
Walter Roberson 2021 年 6 月 23 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

質問済み:

2021 年 6 月 23 日

コメント済み:

2021 年 6 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by