how to example program about enso shifting
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Evelyne Aiyana
2019-7-9
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
2019-7-9
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
2019-7-10
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
2019-7-10
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
2019-7-11
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
2019-7-11
编辑:Geoff Hayes
2019-7-11
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
2019-7-12
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
2019-7-12
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
2019-7-12
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
2019-7-13
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
2019-7-15
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
2019-7-17
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
2019-7-18
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
2019-7-19
编辑:Evelyne Aiyana
2019-7-19
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)