Plotting a single contour to divide a region into two

3 visualizaciones (últimos 30 días)
University
University el 30 de Mzo. de 2024
Comentada: Voss el 31 de Mzo. de 2024
In the figure I attached, I have oscillatory region and non-oscillatory region. Pleas how can I plot a single contour line that will divide the oscillarory region from the non-oscillatory region.
openfig('figure.fig');

Respuesta aceptada

Voss
Voss el 30 de Mzo. de 2024
Here's an example:
% create vectors for x/y non/oscillatory
n = 5;
o_idx = [1 2 6 7 8 11 12 16 21 22];
[xo,yo] = meshgrid(1:n);
xo = xo(:);
yo = yo(:);
xn = xo;
yn = yo;
idx = ismember(1:n^2,o_idx);
xo = xo(idx);
yo = yo(idx);
xn = xn(~idx);
yn = yn(~idx);
% plot the points
figure
plot(xo,yo,'.r','MarkerSize',12)
hold on
plot(xn,yn,'.c','MarkerSize',12)
xlim([0 n+1])
ylim([0 n+1])
% make a contour dividing the regions
c = zeros(n);
c(idx) = 1;
contour(c,'LevelList',0.5,'Color','k')
  8 comentarios
University
University el 31 de Mzo. de 2024
Thank you so much, this works.
Voss
Voss el 31 de Mzo. de 2024
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by