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

조회 수: 30 (최근 30일)
SimTec
SimTec 2021년 6월 23일
댓글: Walter Roberson 2021년 6월 23일
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일
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
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개)

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by