how to calculate the maximum of a probability array

1 vue (au cours des 30 derniers jours)
ELISABETTA BILLOTTA
ELISABETTA BILLOTTA le 11 Mar 2023
Réponse apportée : Voss le 13 Mar 2023
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 commentaires
Edoardo_a
Edoardo_a le 13 Mar 2023
Modifié(e) : Edoardo_a le 13 Mar 2023
Could you upload the 'PP_all' function?
If I am right, you would like to plot not the PP_all value, but the highest value among the different P_x that are used to calculate PP_all?
I think it would be easier to get what you need by modifying the function directly.
ELISABETTA BILLOTTA
ELISABETTA BILLOTTA le 13 Mar 2023
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.

Connectez-vous pour commenter.

Réponse acceptée

Voss
Voss le 13 Mar 2023
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);

Plus de réponses (0)

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by