How to combine two 1D functions into 3D plot?

As the title says, I have a z(x) function and a z(y) function, they are both 1D functions. But I wanna show these 1D functions at the same scene, however, one is about x-axis, the other one is about y-axis, therefore, it should be a 3D plot when they wanna show at the same plot. My code as below:
x = linspace(-1,1,513);
y = linspace(-1,1,513);
[X,Y] = meshgrid(x,y);
Z0 = 625*sinc(25*x)-200*sinc(20*x).*exp(-1i*5*pi*x);
plot3(x,Y,real(Z0),'b')
hold on
Z90 = 625*sinc(25*y) - 50*sinc(5*y).*cos(10*pi*y);
plot3(Y,x,real(Z90),'r')
And I have also attached the plot I want, but I cannot make it, below comment is the figure I wanna get

Antworten (1)

KSSV
KSSV am 12 Okt. 2020
Bearbeitet: KSSV am 12 Okt. 2020

0 Stimmen

x = linspace(-1,1,513);
y = linspace(-1,1,513);
[X,Y] = meshgrid(x,y);
Z0 = 625*sinc(25*X)-200*sinc(20*X).*exp(-1i*5*pi*X);
Z90 = 625*sinc(25*Y) - 50*sinc(5*Y).*cos(10*pi*Y);
surf(X,Y,real(Z0))
hold on
surf(X,Y,real(Z90))
shading interp

3 Kommentare

Tianyao Zhang
Tianyao Zhang am 12 Okt. 2020
Thank you for your answer! But I cannot get the result like the plot shows in the question, I only get this
KSSV
KSSV am 12 Okt. 2020
Use shading interp after surf
Tianyao Zhang
Tianyao Zhang am 12 Okt. 2020
Hi KSSV, sorry to forget the shading interp, but i get the result like below, it is not desired though.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Exploration finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 12 Okt. 2020

Bearbeitet:

am 12 Okt. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by