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 Exchange에서 Weather 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