Clear Filters
Clear Filters

Plotting a single contour to divide a region into two

3 views (last 30 days)
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');

Accepted Answer

Voss
Voss on 30 Mar 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 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!