How to load a table from .csv and skip lines?

Hey all! I am very new to MatLab and am just figuring it all out. I wanted to do some plotting but am unable to do so.
Basically I want plot all values in the age and studyTime column. Unfortunately, because of the whole "table in a csv text file" I am not able to import it or work with it.
I have tried almost every solution I could find but am not able to accomplish something. Also, please use simple code as I am a Python guy and know absolutely nothing of
MatLab.
Thanx in advance :)
BTW, Here is some one of the code I tried ===>
close all;
load student_mat_final.csv age studytime
plot(age,studytime)

 採用された回答

BN
BN 2020 年 4 月 10 日
編集済み: BN 2020 年 4 月 10 日

1 投票

Hi, try this
filename = 'student_mat.csv' % open file (make sure it exist in the current folder)
T = readtable(filename); % read file as table
age = T.age; % read age column
study_time = T.studytime; % read studytime column
area(age, study_time) % plot them
xlabel('Age')
ylabel('Study Time')
title('Age vs Study time plot')
I used area, You can use any types of plot as you want. Look at this amazing page you can choose what you want.

2 件のコメント

Neel Gupta
Neel Gupta 2020 年 4 月 10 日
@Behzad Navidi This works perfectly! A ton of thanks for figuring out my problem!
BN
BN 2020 年 4 月 10 日
My pleasure. Good Luck

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2020 年 4 月 10 日

コメント済み:

BN
2020 年 4 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by