フィルターのクリア

How do I plot a multivariate piecewise continuous function?

4 ビュー (過去 30 日間)
Rohit Sinha
Rohit Sinha 2022 年 4 月 6 日
編集済み: Bruno Luong 2022 年 4 月 7 日
Hi, I wish to plot a mesh and a contour of multivariate piecewise continuous functions but everytime I try something, I end up getting the wrong or no plot at all.
Here is a sample function that I have been trying to plot
which is a rhombic function and must lead to a rhombic contour.
  3 件のコメント
Rohit Sinha
Rohit Sinha 2022 年 4 月 6 日
@Dyuman Joshi The range is mentioned in the problem statement in the conditions. For simplicity, x and y both lie between -1 and 1
Bruno Luong
Bruno Luong 2022 年 4 月 7 日
編集済み: Bruno Luong 2022 年 4 月 7 日
The last and the first domain are intersecting so you have 2 different definitions of your function for example at x=0,y=-1, is f(x,y) = 0-1-1=-2 or 0+1-1=0?

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

回答 (2 件)

Dyuman Joshi
Dyuman Joshi 2022 年 4 月 7 日
k=meshgrid(-1:0.01:1);
for i=1:size(k,1)
for j=1:size(k,2)
if k(i).. & k(j)..
f(i,j)=..;
elseif k(i).. & k(j)..
f(i,j)=..;
end
end
end
surf(-1:0.01:1, -1:0.01:1, f)

Torsten
Torsten 2022 年 4 月 6 日
Why don't you write a simple function for F with 4 if-statements for the 4 cases ?
function value = F(x,y)
if x ... && y ...
value = ...
elseif x ... && y ...
value = ...
elseif x... && y ...
value = ...
elseif x ... && y ...
value = ....
else
disp('x and/or y out of range')
end
end

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by