PLOT CSV FILE IN MATLAB
50 次查看(过去 30 天)
显示 更早的评论
Good Morning,
I am trying to graph the attached .csv file but it does not run correctly, my code is as follows.
t,p = csvread('re.csv',1,0);
y_line_1= tmp(:,7);
x_line_1= tmp(:,3);
plot(x_line_1,y_line_1,'b-')
I appreciate the help.
Willian
X axis: P2
Y axis: P6
0 个评论
采纳的回答
Ankit
2021-7-8
编辑:Ankit
2021-7-8
csvread: The file can only contain numeric values.
I would prefer readtable command. With this command you have flexibility to use variety of import options too. This "opts" object contains properties that control the data import process.
For more info on readtable see the following link - readtable
tmp = readtable('re.csv');
y_line_1= table2array(tmp(:,7));
x_line_1= table2array(tmp(:,3));
plot(x_line_1,y_line_1,'b-')
3 个评论
Jeremy Hughes
2021-7-8
I see this a lot:
table2array(tmp(:,7)) % extracts a sub table then converts it to an array
Which is a complicated way of doing:
tmp.(7) % directly extracts the seventh variable.
Also, in newer releases you could be using:
tmp = readmatrix('re.csv');
Ankit
2021-7-9
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!