Plotting Anonymous Function of two variables
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael Haag
am 19 Sep. 2023
Kommentiert: Michael Haag
am 20 Sep. 2023
Hello,
I have defined the following Anonymous Function of two variables:
f1 = @(x) erf(x(1))+cos(x(2));
When writing the command for plotting via fsurf
fsurf(f1,[-5 0 -5 5])
I get the following warning and my figure remains empty:
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize
your function to return an output with the same size and shape as the input arguments.
So, what am I doing wrong?
I know that I can plot the function with
f1 = @(x,y) erf(x)+cos(y);
fsurf(f1,[-5 0 -5 5])
but I want to plot it like at the beginning.
How can I plot a Anonymous Function that is defined as mentioned at the beginning?
Regards,
Michael
5 Kommentare
Dyuman Joshi
am 20 Sep. 2023
"the objective function has to be defined as mentioned"
I am bit skeptical about "has to".
Can you give more details about what you are trying to? Can you share the objective function?
Akzeptierte Antwort
Matt J
am 19 Sep. 2023
f1 = @(x) erf(x(1))+cos(x(2));
fsurf(@(x1,x2) f1([x1,x2]) , [-5 0 -5 5])
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!