You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
how to example program about enso shifting
4 views (last 30 days)
Show older comments
hy everyone, i new to matlab. i use matlab 2013a. my problem is not understanding in making programs in the form of looping functions for different years. my data is in the form of netcdf. the matrix of my data is 855*6. 855, starting 1948 until 2019 and each year consist of 12 months. the different years are for example 1987, 1998, 2000, and 2006. i ask ou thank you for giving me advice and hel with my problem.
15 Comments
Evelyne Aiyana
on 9 Jul 2019
if function used to plot images for strong el nino and strong nina. el nino was strong when it happened according to different year oni index. Because the year is different how to make the looping of the year the occurrence of the strong el nino as well as the strong nina
Geoff Hayes
on 9 Jul 2019
Evelyne - are you just interested in the years 1987, 1998, 2000, and 2006? Can we assume that all years from 1948-2019 with all twelve months are present in your 855x6 matrix?
Evelyne Aiyana
on 10 Jul 2019
I'm not interested in this month but it's just an example.
data from 1948 to 2019 are indeed in the 855 * 6 matrix.
I am confused in determining the different years of repetition on the matrix because the repetition does not have a pattern.
The data I need is 1957, 1958, 1963, 1964, 1965, 1966, 1969, 1972, 1973, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2002, 2009, 2010, 2015, 2016 for the El Nino period was strong.
and 1950, 1955, 1971, 1973, 1974, 1975, 1988, 1989, 1998, 1999, 2000, 2007, 2008, 2011 for the period of strong leadership.
Geoff Hayes
on 10 Jul 2019
Evelyne - to get the monthly data corresponding to a specific year, your code could look like
initialYear = 1948;
targetYear = 1957;
indexOfJanuaryInTargetYear = (targetYear - initialYear) * 12 + 1;
monthlyDataForTargetYear = Z(indexOfJanuaryInTargetYear:(indexOfJanuaryInTargetYear+11), :);
where Z is your 855x6 matrix (and I'm assuming that all twelve months for each year appears in the Z matrix).
Evelyne Aiyana
on 11 Jul 2019
Sorry, my answer yesterday was wrong, so the year used was not the month. I want the loop function for different years, what is the solution to solving it?
Geoff Hayes
on 11 Jul 2019
Edited: Geoff Hayes
on 11 Jul 2019
Evelyne - please clarify what you mean by so the year used was not the month.. As for the loop functioning for different years, do you mean that you want to loop over particular years and ignore others?
yearsOfInterest = [1948 1973 1982 1995];
initialYear = 1948;
for k = yearsOfInterest
indexOfJanuaryInTargetYear = (k - initialYear) * 12 + 1;
monthlyDataForTargetYear = Z(indexOfJanuaryInTargetYear:(indexOfJanuaryInTargetYear+11), :);
% do something
end
Evelyne Aiyana
on 12 Jul 2019
I want to group different years. And I can classify per year. the problem is the combination of several tables into one table with double data types?
Geoff Hayes
on 12 Jul 2019
What are the several tables? I thought that you just had one matrix... Or do you consider a table to be twelve months of data from one particular year?
Guillaume
on 12 Jul 2019
Any reason you're sticking to R2013a? Don't you have access to newer versions.
Grouping data is extremely easy in newer versions of matlab. It can be just one line of code. In R2013a, it will require more effort.
R2013a does not have what matlab call tables. These were introduced in R2013b. You probably mean matrices.
In any case, you need to spend more time explaining what you need to achieve (besides I want to group some years). So far, you've not been clear at all. And do not tell us how to achieve it, just tell us what you want. What the start point is, and what the end point should be. We will know how to do it efficiently (probably with no loops). Ideally provide a simple example of inputs and show us what the output should be for that.
Evelyne Aiyana
on 13 Jul 2019
I can classify the different years. But when I want to plot there is an error, the size of x must match the size of Z or the number of coloumns of Z?
Geoff Hayes
on 15 Jul 2019
Evelyne - please show your code and describe how the inputs to plot are constructed and their dimensions (as the error is indicating there is a problem with that).
Evelyne Aiyana
on 17 Jul 2019
y_m1=y_m(:,7:150);
contour(lon(:),y,y_m1);
My data uses reanalysis data (4 dimensions), namely longitude, latitude, time, and level. Then the latitude is averaged and the data becomes 3 dimensional. The length is around the world (144x1), level (12X1), and this time is 14 years consisting of wind data with a 168X144 matrix. I want to plot the longitude with a level and get a 2-dimensional graph using contours (xy, z) and the results show the center of increase of el nino from the data value of that time?
Geoff Hayes
on 18 Jul 2019
the latitude is averaged...why the latitude and not one of the other parameters? Can you attach some of your data? Can you show some of your code? Are you able to get the years that you want? How does this data relate to the 855x6 array?
Evelyne Aiyana
on 19 Jul 2019
Edited: Evelyne Aiyana
on 19 Jul 2019
code:
month=[t2 angin_o2'];
%%%definisikan fungsi waktu%%%
yr= month(month(:,1)>=0,:);
%%PEMBAGIAN TAHUN EL NINO KUAT
yr = month (month(:,1)>=0,:);
yr_1951= yr ((yr(:,1)==1951),:);
yr_1957= yr ((yr(:,1)==1957),:);
yr_1963= yr ((yr(:,1)==1963),:);
yr_1965= yr ((yr(:,1)==1965),:);
yr_1966= yr ((yr(:,1)==1966),:);
yr_1969= yr ((yr(:,1)==1969),:);
yr_1972= yr ((yr(:,1)==1972),:);
yr_1982= yr ((yr(:,1)==1982),:);
yr_1983= yr ((yr(:,1)==1983),:);
yr_1987= yr ((yr(:,1)==1987),:);
yr_1991= yr ((yr(:,1)==1991),:);
yr_1992= yr ((yr(:,1)==1992),:);
yr_1997= yr ((yr(:,1)==1997),:);
yr_1998= yr ((yr(:,1)==1998),:);
yr_2015= yr ((yr(:,1)==2015),:);
yr_2016= yr ((yr(:,1)==2016),:);
%%%gabungkan
y_m = [yr_1951; yr_1957;yr_1963;yr_1965;yr_1966;yr_1972;yr_1982;yr_1983;yr_1987;yr_1992;yr_1997;yr_1998;yr_2015;yr_2016;]
y_m1= y_m(:,7:150);
% y_m2=y_m1';
h=y_m1(1:12,:)
contour(lon(1:12:144), y,h);
% y_m1=y_m(:,7:150);
% contour(lon(:),y,y_m1);
latitude must be averaged as well as in my research the x, y, z contour plot is needed between longitude and level. The value of z expresses vertical wind data.
I have received the desired year related to the 855 * 6 array and already combined with vertical wind data.
and when I want the plot there is an error that is
Error using contour (line 81)
The size of X must match the size of Z or the number of columns of Z.
Error in baca_reanalysis_ganbatte100 (line 107)
contour(lon(1:12:144), y,h);
how is the solution? thank you in advance
Answers (0)
See Also
Categories
Find more on Geographic Plots in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)