how to calculate the maximum of a probability array
조회 수: 1 (최근 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
Edoardo_a
2023년 3월 13일
편집: Edoardo_a
2023년 3월 13일
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.
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!