Plotting a single contour to divide a region into two
3 views (last 30 days)
Show older comments
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');
0 Comments
Accepted Answer
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
More Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!