How to plot a one year rainfall data

I have a 31X12 rainfall data and i want it to plotted in 2D from January 1 to December 31. X- axis will be January 1 to December 31 2010 and Y will be the data from the 31x12 matrix. Thank you

3 件のコメント

Adam Danz
Adam Danz 2019 年 4 月 29 日
How are your date stamps stored? Are they in a [1x12] or [31x1] vector? Are they in datetime() format? Is your data a timetable?
More detail would be helpful. Even better, a sample of your data.
STS-95
STS-95 2019 年 4 月 29 日
Here is the data.
Adam Danz
Adam Danz 2019 年 4 月 29 日
編集済み: Adam Danz 2019 年 4 月 29 日
Have you read the data into matlab yet? There are multiple ways to do that and if an answer is provided that doesn't match the format of your data in matlab, it won't be as useful to you.

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

 採用された回答

Adam Danz
Adam Danz 2019 年 4 月 29 日
編集済み: Adam Danz 2019 年 4 月 29 日

0 投票

I read in the data using readtable() but you can use any method as long as your data are organized into an [m x n] array with m days and n months (NaNs are used at the end of short months).
A = readtable('2010.csv', 'ReadRowNames', 1);
A.Var13 = []; %get rid of extra column
figure
ph = plot(table2array(A), 'LineWidth', 2);
axis tight
xlabel('day of month')
ylabel('rain fall')
legend(ph, A.Properties.VariableNames)
You can use a different color scheme with 12 unique colors, of course.
190429 185356-Figure 1.jpg

3 件のコメント

STS-95
STS-95 2019 年 4 月 29 日
Is there a way to plot this using one line and x-axis has 365 days. Thank you so much.
Adam Danz
Adam Danz 2019 年 4 月 29 日
編集済み: Adam Danz 2019 年 4 月 29 日
Yes, there's a way. Why do I have the feeling you didn't try to figure out a way to do it?
data = table2array(A);
x = datetime('Jan/01/2010') : 1 : datetime('Dec/31/2010');
data(isnan(data)) = []; %now it's a vector without the NaN fillers.
figure
190429 191956-Figure 3.jpg
Adam Danz
Adam Danz 2019 年 4 月 29 日
"I've searched for the answer but can't find the right answer. Thank you so much. BTW, I'm absolutely beginner and I started using matlab just last week."
Make sure you go through each line of my code and understand what I'm doing. Most of it is at a beginner's level so it will be a good learning opportunity.

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

その他の回答 (1 件)

STS-95
STS-95 2019 年 4 月 29 日

0 投票

I've searched for the answer but can't find the right answer. Thank you so much. BTW, I'm absolutely beginner and I started using matlab just last week.

カテゴリ

ヘルプ センター および File ExchangeWeather and Atmospheric Science についてさらに検索

タグ

質問済み:

2019 年 4 月 29 日

コメント済み:

2019 年 4 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by