Hello, I have a question. I am trying to solve a optimization problem but my function has 3 variables and I am not sure how to plot a 3d diagram of 3 variable function.

1 件のコメント

VBBV
VBBV 2021 年 5 月 3 日
Use plot3 function

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

 採用された回答

KSSV
KSSV 2021 年 5 月 3 日

1 投票

Read about surf.

5 件のコメント

Sanket Sutar
Sanket Sutar 2021 年 5 月 3 日
編集済み: Sanket Sutar 2021 年 5 月 3 日
I forgot to mention the objective function is a nonlinear equation with three variables. Will surf function work? Thank you.
KSSV
KSSV 2021 年 5 月 3 日
What ever the function is...if you have matrix at the end, you can use surf.
Sanket Sutar
Sanket Sutar 2021 年 5 月 4 日
Hello KSSV, I read and tried using surf but can't seem to figure it out. I am very new to MATLAB.
And this is my function - (x+5).^2+(y+8).^2+(z+7).^2+(2.*x.^2.*y.^2)+(4.*x.^2.*z.^2);
Can you please point me in the right direction?
KSSV
KSSV 2021 年 5 月 4 日
m = 10 ;
x = linspace(0,1,m) ;
y = linspace(0,1,m) ;
z = linspace(0,1,m) ;
[x,y,z] = meshgrid(x,y,z) ;
f = (x+5).^2+(y+8).^2+(z+7).^2+(2.*x.^2.*y.^2)+(4.*x.^2.*z.^2);
figure
hold on
for i = 1:size(f,3)
surf(x(:,:,i),y(:,:,i),z(:,:,i),f(:,:,i)) ;
end
view(3)
Read about slice.
Sanket Sutar
Sanket Sutar 2021 年 5 月 5 日
Thank you so much for your help !!!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

質問済み:

2021 年 5 月 3 日

コメント済み:

2021 年 5 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by