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 个评论

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.
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.

请先登录,再进行评论。

 采纳的回答

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 个评论

Is there a way to plot this using one line and x-axis has 365 days. Thank you so much.
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
"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
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 Exchange 中查找有关 Weather and Atmospheric Science 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by