how to plot column vs column from csv file using readmatrix?
33 次查看(过去 30 天)
显示 更早的评论
I have a csv file that is named data,that contains 03 columns: clock,volt_a and volt_b:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/661970/image.png)
array=readmatrix('data.csv');
plot(array)
when I readmatrix the csv file, it shows the data without its column's name.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/661975/image.png)
0 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!