Using surf with two-dimensional function handle argument

15 Ansichten (letzte 30 Tage)
jbolin
jbolin am 13 Feb. 2018
Beantwortet: Walter Roberson am 13 Feb. 2018
How might I use meshgrid and surf to plot a surface of a two-dimensional function handle?
So instead of f(x1,x2), f(x) when x=[x1 x2]
f =@(x1,x2) x1.^2 + x2.^2;
t = linspace(-10,10,20);
[xx,yy] = meshgrid(t,t);
surf(xx,yy,f(xx,yy))

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 13 Feb. 2018
f =@(x) x(1).^2 + x(2).^2;
t = linspace(-10,10,20);
[xx,yy] = meshgrid(t,t);
surf(xx,yy,arrayfun(@(x,y)f([x,y]),xx,yy))

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D 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!

Translated by