How can I plot value of function (dependant on 2 variables) in 3D ?

I have a function 'Fn' whose value depends on two variables, X and Y... If X=[i1,i2,i3] Y=[j1,j2,j3] Fn returns a 3x3 matrix calculating Fn(x,y) for each combination of x and y possible... How can I plot this in 3D?

 Réponse acceptée

Stephen23
Stephen23 le 11 Fév 2017
Modifié(e) : Stephen23 le 11 Fév 2017
Try using surf or any of the other 3D plot functions:
Xv = [i1,i2,i3];
Yv = [j1,j2,j3];
Zm = Fn(Xv,Yv);
[Xm,Ym] = ndgrid(Xv,Yv);
surf(Xm,Ym,Zm)

1 commentaire

Thanks man!!! I've been trying to figure this out since last two days!!! :') the 'ndgrid' function was the key!! Good job mate! =)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by