how to calculate the maximum of a probability array

5 次查看(过去 30 天)
i have such a script where PP_all is a 100651x1 matrix and it derives from this formula
PP_all=1-((1-P_1_4).*(1-P_1_6).*(1-P_1_9).*(1-P_2_2).*(1-P_6).*(1-P_7).*(1-P_8).*(1-P_9 ).*(1-P_10));
at each point of the grid, therefore, the product of these values is displayed.
Now instead, in each point of the grid, I have to visualize the maximum value among all these probabilities that created me PP_all. It is as if they were a series of grids superimposed on each other and in the end, at each point, I only display the maximum value of all and create a new grid.
So I need to obtain another 100651x1 matrix (useful for visualizing the final map) where each point of the grid represents the maximum value among all the probabilities P_1_4, P_1_6,P_2_2...P_10.
Can anyone help me?
longrd=0:0.1:40;
latgrd=30:0.1:55;
limlon=[min(longrd),max(longrd)];
limlat=[min(latgrd),max(latgrd)];
ic=0;
for i=1:length(longrd)
for j=1:length(latgrd)
ic=ic+1;
lonlatgrd(ic,1)=longrd(i);
lonlatgrd(ic,2)=latgrd(j);
end
end
figure()
for i=1:length(longrd)
for j=1:length(latgrd)
XX(i,j)=longrd(i);
YY(i,j)=latgrd(j);
isel1=find(lonlatgrd(:,1)==longrd(i));
isel2=find(lonlatgrd(isel1,2)==latgrd(j));
isel=isel1(isel2);
ZZ(i,j)=PP_all(isel));
end
end
contourf(XX,YY,ZZ,500,'linecolor','none');
colormap jet
hold on
load coastlines.mat;
xlim([min(longrd), max(longrd)]);
ylim([min(latgrd), max(latgrd)]);
colorbar;
pbaspect([1 1 1]);
  2 个评论
ELISABETTA BILLOTTA
PP_all is not a function but a .mat file that derives from
PP_all=1-((1-P_1_2).*(1-P_1_6).*(1-P_1_9).*(1-P_2_2).*(1-P_6).*(1-P_7).*(1- P_8).*(1-P_9 ).*(1-P_10)).
I am attaching it but I don't have to change a function: it is as if I had to superimpose the grids P_1_4, P_1_6,P_1_9...P_10 and then, once superimposed, choose what is the maximum illness for each point of the grid. Then recreate a 100651x1 matrix consisting of all the maximum values.

请先登录,再进行评论。

采纳的回答

Voss
Voss 2023-3-13
PP_temp = [P_1_2, P_1_6, P_1_9, P_2_2, P_6, P_7, P_8, P_9, P_10];
PP_max = max(PP_temp,[],2);

更多回答(0 个)

类别

Find more on Descriptive Statistics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by