How to use surf ?

I have a function f(i,j). How to plot a 3D graph (like surf) for f(i,j) vs x(i) vs y(j) ?

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 10 日

0 投票

i=1:10
j=1:10
[ii,jj]=meshgrid(i,j)
x=sin(ii)
y=cos(jj)
f=x.^2+y.^2
surf(x,y,f)

1 件のコメント

chaos
chaos 2014 年 5 月 10 日
you defined the f.
But I have a predefined function f. I have to plot it against two different variables x and y . f is not a direct function of x and y.
For example: Take f(i,j) = i*j [ for i=1:4,j=1:3 ]
x = [5,6,7,10]; y=[2,-3,4]; Now I have to plot f(i,j) vs x(i) vs y(j)

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2014 年 5 月 10 日

コメント済み:

2014 年 5 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by