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 commentaires

Adam Danz
Adam Danz le 29 Avr 2019
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 le 29 Avr 2019
Here is the data.
Adam Danz
Adam Danz le 29 Avr 2019
Modifié(e) : Adam Danz le 29 Avr 2019
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.

Connectez-vous pour commenter.

 Réponse acceptée

Adam Danz
Adam Danz le 29 Avr 2019
Modifié(e) : Adam Danz le 29 Avr 2019
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 commentaires

STS-95
STS-95 le 29 Avr 2019
Is there a way to plot this using one line and x-axis has 365 days. Thank you so much.
Adam Danz
Adam Danz le 29 Avr 2019
Modifié(e) : Adam Danz le 29 Avr 2019
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 le 29 Avr 2019
"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.

Connectez-vous pour commenter.

Plus de réponses (1)

STS-95
STS-95 le 29 Avr 2019

0 votes

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.

Catégories

En savoir plus sur Weather and Atmospheric Science dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by