Generating a 3D plot

3 次查看(过去 30 天)
Matlab2010
Matlab2010 2015-4-21
I have two 1D functions
  • Z1 =f(y)
  • Z2 =g(x)
Where Z1, Z2, x and y are Nx1 vectors.
I wish to combine these and plot the resulting 2D function as a 3D plot. Combination is by a weighting function W = [w1 w2], where w1+w2=1.0.
  • Z = h(x, y) = w1.*f(y) + w2. g(x)
Please can someone give me some example code to generate h() and plot it in a 3D graph.
Thank you
  2 个评论
Titus Edelhofer
Titus Edelhofer 2015-4-21
Hi,
there is an important piece of information missing: what is the relation between Z1, Z2 and h? Is e.g.
h(x,y) = f(y) * g(x)
or
h(x,y) = f(y) + g(x)
or ... ?
Titus
Matlab2010
Matlab2010 2015-4-21
apologies. updated.

请先登录,再进行评论。

回答(1 个)

Michael Haderlein
Michael Haderlein 2015-4-21
I guess with "3D-plot" you mean a surface plot? So it would be like
x=linspace(0,1,50); %I just choose random values here
y=linspace(-1,1,80);
f=y.^2; %also here, I just do something random
g=exp(-x);
W=rand(2,1);
[F,G]=meshgrid(f,g);
Z=W(1)*F+W(2)*G;
surf(F,G,Z) %or
surf(f,g,Z) %or
surf(y,x,Z)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by