Regarding 3D plots with Matlab

조회 수: 4 (최근 30일)
Mads Svendsen-Tune
Mads Svendsen-Tune 2011년 3월 22일
Hi - im trying to do a 3D plot in Matlab
I have a user defined function of the form:
[Number,~,...] = myfunc(parameter,arg2,...)
The first output argument (Number) is a real number. Parameter is a vector in 2 dimensional space. Can someone tell me how to plot Number on the z - axis given a prespecified set to which parameter belongs.
Thanks

채택된 답변

Matt Tearle
Matt Tearle 2011년 3월 23일
So what kind of visualization do you want at the end? Do you want a surface? In which case you could do something like
x = 0:0.1:1;
y = -1:0.05:2;
[X,Y] = meshgrid(x,y);
params = [X(:),Y(:)];
n = size(params,1);
Z = zeros(n,1);
for k=1:n
Z(k) = myfunc(params(k,:),...);
end
Z = reshape(Z,size(X));
surf(X,Y,Z)
  댓글 수: 1
Mads Svendsen-Tune
Mads Svendsen-Tune 2011년 3월 23일
Thanks alot, that seems to be exactly what im looking for.

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

추가 답변 (1개)

Matt Tearle
Matt Tearle 2011년 3월 22일
I'm not sure I understand what you're after. It sounds a bit like
plot3(parameter(1),parameter(2),Number,'o')
  댓글 수: 1
Mads Svendsen-Tune
Mads Svendsen-Tune 2011년 3월 23일
I want to plot my function, f: R^2 -> R. My function f takes as input a parameter vector and some other stuff. I want to plot my function for
parameter1 = [ 0,1 ] and parameter2 = [0.5 , 1] say.
Thank you for helping out!

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

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by