フィルターのクリア

Which approach is useful here to get a plot?

2 ビュー (過去 30 日間)
Trim Dim
Trim Dim 2022 年 12 月 1 日
コメント済み: Trim Dim 2022 年 12 月 2 日
I have this function with two input parameters
I'm used to graphing functions with a single parameter.
But how can you get an output with two parameters?
How will it be passed to the function if I create two arrays
for each input parameter? I'd want to have input in the
range [0,1]. Is there another example?

採用された回答

KSSV
KSSV 2022 年 12 月 1 日
Check and then use. I have quickly typed it without much thought.
n1 = linspace(0,1) ;
n2 = linspace(0,1) ;
n = cat(3,n1,n2) ;
% First summation
T1 = zeros(size(n1)) ;
for i = 1:2
T1 = T1 + -1/2*n(:,:,i)+1/4*n(:,:,i).^4 ;
end
% Second summation
for i = 1:2
T2 = n(:,:,i).^2 ;
for j = 1:2
if j ~= i
T2 = T2.*n(:,:,j).^2 ;
end
end
end
iwant = T1+T2 ;
  3 件のコメント
KSSV
KSSV 2022 年 12 月 1 日
Perfect..
n1 = linspace(0,1) ;
n2 = linspace(0,1) ;
[n1,n2] = meshgrid(n1,n2) ;
n = cat(3,n1,n2) ;
% First summation
T1 = zeros(size(n1)) ;
for i = 1:2
T1 = T1 + -1/2*n(:,:,i)+1/4*n(:,:,i).^4 ;
end
% Second summation
for i = 1:2
T2 = n(:,:,i).^2 ;
for j = 1:2
if j ~= i
T2 = T2.*n(:,:,j).^2 ;
end
end
end
iwant = T1+T2 ;
surf(n1,n2,iwant)
Trim Dim
Trim Dim 2022 年 12 月 2 日
Although the output is very similar but in the expected output
(as in my attachment) there is a bump in the center
and the edges show minima at n1=1 and n1=0 and also at
n2=1 and n2=0.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by