How select csv file data and plot graph (help)

Hello guys , how to select data from row 2? Because I really have no idea how to remove the first row...The row number is not fixed. I just need the data in column 1 and column 2 to plot graph. One more question , can I use the number in string( str) form to plot graph? The data in column 1 and column 2 are in str form. Thanks . ^^

回答 (1 件)

Nikeaton Premnath
Nikeaton Premnath 2018 年 3 月 8 日

0 投票

Don't have to remove row 1. Matlab doenst take it into account since it's not a value. It should start from row 2 by itself.
Check this example I did.
For me to plot the force vs stroke, I use:
%%Expt 1
[v1,T1,v1T1]=xlsread('c2r11.csv');
x1=v1(:,3);y1=v1(:,2);
figure(1)
plot(x1,y1, 'color', 'r')
Works fine for me. No issues

4 件のコメント

zhixuan hong
zhixuan hong 2018 年 3 月 8 日
thanks for your reply, if my pc don't hv Excel ,so this code xlsread() cant use right ?
Nikeaton Premnath
Nikeaton Premnath 2018 年 3 月 8 日
Hi,
I'm not 100% sure, but MATLAB doesn't open Excel when I code in xlxread(). MATLAB should have it's own inbuilt function for this. Give it a shot and see. Might work.
zhixuan hong
zhixuan hong 2018 年 3 月 8 日
Still error ... >> TEST2 Warning: Could not start Excel server for import, 'basic' mode will be used. Refer to HELP XLSREAD for more information. > In xlsread (line 191) In TEST2 (line 1) Error using xlsread (line 251) Unable to read XLS file C:\Users\HongZhiX\Documents\MATLAB\V.csv. File is not in recognized format.
Error in TEST2 (line 1) [v1,T1,v1T1]=xlsread('V.csv');
Nikeaton Premnath
Nikeaton Premnath 2018 年 3 月 8 日
Make sure the script and the csv file are in the same folder.
Also; "TEST2 Warning: Could not start Excel server for import" I think you then require excel for this.
Sorry.

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

タグ

質問済み:

2018 年 3 月 7 日

コメント済み:

2018 年 3 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by