Plotting a single contour to divide a region into two
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Voss
2024-3-30
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')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!