contourf min max is it possible?

20 次查看(过去 30 天)
Casper Stroem
Casper Stroem 2017-10-10
评论: Pronoy Das 2020-12-25
I have a large matrix Cp and using contourf(Cp) Is it possible to mark min and max values in the plot ?

回答(4 个)

Chad Greene
Chad Greene 2017-10-10
Here's an example you can run. If Cp is a matrix like this:
Cp = peaks(1000);
and you want to make a contourf plot, specify the values of the contour lines. Here I'm doing -3 to 2 at intervals of 0.75.
contourf(Cp,-3:0.75:2)

Walter Roberson
Walter Roberson 2017-10-10
[minCp, minidx] = min(Cp(:));
[minrow, mincol] = sub2ind(size(Cp), minidx);
minleg = sprintf('Minima @ (%d,%d) = %.2f', mincol, minrow, minCp);
[maxCp, maxidx] = max(Cp(:));
[maxrow, maxcol] = sub2ind(size(Cp), maxidx);
maxleg = sprintf('Maxima @ (%d,%d) = %.2f', maxcol, maxrow, maxCp);
hold on
lh = plot( mincol, minrow, 'g+', maxcol, maxrow, 'r+', 'MarkerSize', 15);
legend(lh, {minleg, maxleg} );
hold off

Casper Stroem
Casper Stroem 2017-10-10
here is my contour plot 551x49 matrix, and i would like to show min and max value of Cp the exact position on the plot

Casper Stroem
Casper Stroem 2017-10-10
Walter I am getting an error trying your solution
  1 个评论
Pronoy Das
Pronoy Das 2020-12-25
It should be:
[maxrow, maxcol] = ind2sub(size(Cp), maxidx);
and not
[maxrow, maxcol] = sub2ind(size(Cp), maxidx);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by