Plotting graph from the data of a csv file

Hi, I am using MATLAB R2016a. I have got into a situation where I have to parse through a csv file and draw a plot using them. I am using the following code for that. close all; file = 'test.csv';
Array = csvread(file); col1 = Array(:, 1); col2 = Array(:, 2); plot(col1, col2)
There are total 6 columns in the csv file. I am getting the following errors.
Error using dlmread (line 147) Mismatch between file and format string. Trouble reading 'Numeric' field from file (row number 1, field number 1) ==> /in X,/in Y,/z X,/z Y,/out X,/out Y\n
Error in csvread (line 48) m=dlmread(filename, ',', r, c);
Error in untitled (line 4) Array = csvread(file);
Can anyone suggest me a solution? Thanks in advance.
Regards
Saikat Chatterjee

1 件のコメント

Nithya Ravi
Nithya Ravi 2020 年 5 月 7 日
How to merge the two arrays [col1 col2] into a single variable to perform mean?

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

 採用された回答

Benjamin Kraus
Benjamin Kraus 2016 年 8 月 2 日

1 投票

My recommendation is to try the "Import Data" wizard (look for the "Import Data" button on the tool strip). Select your file, set up how you want to import your data, and then you can generate a script to automate the importing in the future.
If that doesn't work, can you post a few lines of the CSV file? Either real data or arbitrary data in the same format?

2 件のコメント

Skot
Skot 2016 年 8 月 3 日
編集済み: Skot 2016 年 8 月 3 日
Thanks a lot Benjamin, it worked.
Jesus Beltran
Jesus Beltran 2020 年 12 月 11 日
What do we do with the generated script?

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

その他の回答 (0 件)

カテゴリ

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

製品

質問済み:

2016 年 7 月 29 日

コメント済み:

2020 年 12 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by