plot a function in 3D

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일

0 개 추천

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

Dimitris
Dimitris 2011년 8월 13일
the result does not look correct plus where I do exactly the same for
t = linspace(0,1,RESOLUTION);
i get a different result for that part of the graph
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일

0 개 추천

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?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by