contourf min max is it possible?
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a large matrix Cp and using contourf(Cp) Is it possible to mark min and max values in the plot ?
0 Kommentare
Antworten (4)
Chad Greene
am 10 Okt. 2017
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)
0 Kommentare
Walter Roberson
am 10 Okt. 2017
[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
am 10 Okt. 2017
1 Kommentar
Pronoy Das
am 25 Dez. 2020
It should be:
[maxrow, maxcol] = ind2sub(size(Cp), maxidx);
and not
[maxrow, maxcol] = sub2ind(size(Cp), maxidx);
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!