Which approach is useful here to get a plot?
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
KSSV
on 1 Dec 2022
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 Comments
KSSV
on 1 Dec 2022
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)
More Answers (0)
See Also
Categories
Find more on Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!