Which approach is useful here to get a plot?
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!