フィルターのクリア

How to plot the region corresponding to an inequality?

62 ビュー (過去 30 日間)
Dimitrios Anagnostou
Dimitrios Anagnostou 2022 年 2 月 10 日
コメント済み: Andrew Sol 2023 年 1 月 21 日
I want to plot create the region plot for the inequality for . In Mathematica this can be done by
RegionPlot[y - x^2 >= 0, {x, -Sqrt[3], Sqrt[3]}, {y, 0, 3}, FrameLabel -> {"x", "y"}]
producing the following plot
How can one produce a similar plot in Matlab? The best I could do was using the spy function as follows
h = 0.01;
[x,y] = meshgrid(-sqrt(3):h:sqrt(3),0:h:3);
e = zeros(size(x));
Z = y-x.^2;
figure(1)
spy(Z >= e);
xlabel('x'), ylabel('y')
Here is another try
clear
h = 0.05;
[x,y] = meshgrid(-sqrt(3):h:sqrt(3),0:h:3);
ineq = y-x.^2 >= 0;
f = double(ineq);
figure(2)
surf(x,y,f);
xlabel('x'), ylabel('y')
view(0,90)
Any ideas? Thank you very much in advance.

採用された回答

KSSV
KSSV 2022 年 2 月 10 日
You are good to go with second method:
h = 0.01;
[x,y] = meshgrid(-sqrt(3):h:sqrt(3),0:h:3);
% e = zeros(size(x));
Z = y-x.^2;
idx = double(Z>=0) ;
figure(1)
pcolor(x,y,idx)
shading interp
xlabel('x'), ylabel('y')
  3 件のコメント
KSSV
KSSV 2022 年 2 月 10 日
編集済み: KSSV 2022 年 2 月 10 日
h = 0.01;
[x,y] = meshgrid(-sqrt(3):h:sqrt(3),0:h:3);
% e = zeros(size(x));
Z = y-x.^2;
idx = double(Z>=0) ;
figure(1)
% spy(Z >= 0);
% xlabel('x'), ylabel('y')
pcolor(x,y,idx)
shading interp
cmap = [255 255 255;0 0 255]/255 ;
colormap(cmap)
Andrew Sol
Andrew Sol 2023 年 1 月 21 日
How can I add a grid to this plot?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by