Highlight Specific Contour Levels of a 2D array

조회 수: 4 (최근 30일)
HC98
HC98 2024년 3월 14일
답변: Voss 2024년 3월 14일
I follow the example of the documentation here and I get stuck because I have an array called ``simdata`` which is 100 x 3200. I want to plot a contourf using the example I included here. How can I do this with a 2D array?
Z = peaks(100);
zmin = floor(min(Z(:)));
zmax = ceil(max(Z(:)));
zinc = (zmax - zmin) / 40;
zlevs = zmin:zinc:zmax;
% Plot the contour lines.
figure
contour(Z,zlevs)
zindex = zmin:2:zmax;
% Retain the previous contour plot. Create a second contour plot and use zindex to highlight contour lines at every other integer value. Set the line width to 2.
hold on
contour(Z,zindex,'LineWidth',2)
hold off

답변 (1개)

Voss
Voss 2024년 3월 14일
Z in the example is a 2D array, so just substitute your 2D array in for Z.
That is, replace
Z = peaks(100);
with
Z = simdata;
And keep the rest of the code the same as in the example.

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by