plot a function in 3D

2 ビュー (過去 30 日間)
Dimitris
Dimitris 2011 年 8 月 12 日
I have variables a and b both defined in [-1,+1] and the function c = a / (a + b)
How can I plot c in 3D to visualize the function?

採用された回答

Walter Roberson
Walter Roberson 2011 年 8 月 13 日
RESOLUTION=20; %increase this for a finer grid
t = linspace(-1,1,RESOLUTION);
[a,b] = ndgrid(t,t);
c = a./(a+b);
surf(a,b,c);
It is, however, not possible to plot it as a continuous surface, as your graphics display only has discretized output locations ("pixels").
  3 件のコメント
bym
bym 2011 年 8 月 13 日
why do you think it does not look correct?
Dimitris
Dimitris 2011 年 8 月 14 日
it is correct. the resolution is too coarse and confused me. thanks for your help.

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

その他の回答 (1 件)

bym
bym 2011 年 8 月 12 日
a= rand(10,1)*2-1
b=rand(10,1)*2-1
c=a./(a+b)
scatter3(a,b,c)
  1 件のコメント
Dimitris
Dimitris 2011 年 8 月 12 日
thanks, but can I plot it as a continuous surface. For all values, not just random samples?

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by