Slice of a surface plot created by 2D data

45 次查看(过去 30 天)
Hi, I have been trying to create a slice though my surface plot which is created with stacked 2D data.
Fs = 3000;
tspan = 0 : 1/Fs :15;
topt = 3
j = topt-1.0 : 0.05 : topt+4.0
---------------------------------------------------------------
delta_r1 = zeros(length(tspan), length(j));
delta_r2 = zeros(length(tspan), length(j));
for ii = 1:numel(j)
t_THz = j(ii);
delta_r1(:,ii) = Fourier1P - fourier1P(:,ii);
delta_r2(:,ii) = Fourier2P - fourier2P(:,ii);
end
delay = zeros(1,length(j));
for ii = 1:numel(j)
t_THz = j(ii);
delay(ii) = t_THz - topt;
end
yMat = repmat(delay, numel(tspan),1);
xMat = repmat(F1.',1,length(j));
plot3(xMat,yMat,delta_r1)
xlim([358 362.5])
zlim([-0.4e-4 2e-4])
xlabel('Frequency (THz)','Rotation', -15)
ylabel('Delay (ps)','Rotation', 23)
title('x_1(f)')
view([19.245913 34.150412])
figure
surf(xMat,yMat,delta_r1)
xlim([358.5 361.7])
zlim([-0.4e-4 2e-4])
xlabel('Frequency (THz)','Rotation',-15)
ylabel('Delay (ps)','Rotation',23)
view([40.018393 23.670967])
colormap(jet)
shading interp
where
delta_r1
and
delta_r2
are 2D arrays of size 45001×101.
I want to create a slice though x = 360.9 so that I can get the side view of the oscillation.
What I have now is this:
x = linspace(358,362.5,length(tspan))
delay
[X,Y] = meshgrid(x,delay)
yq = linspace(-1,4,101)
xq = linspace(360.9,360.9,101)
zq = interp2(X,Y,delta_r1',xq,yq);
dq = sqrt((xq-360.9).^2 + (yq+1).^2);
plot(dq,zq)
axis([min(dq),max(dq),-0.4e-4,2e-4])
I get this plot
It's a straight line rather than an oscillation.
Does anyone know how to fix it?
  1 个评论
Thiago Henrique Gomes Lobato
The problem may be in your interpolation function since you're attributing different position values to your calculated results. You may try something like this:
zq = interp2(xMat,yMat,delta_r1,xq,yq);
dq = sqrt((xq-360.9).^2 + (yq+1).^2);
plot(dq,zq)

请先登录,再进行评论。

回答(1 个)

Rajani Mishra
Rajani Mishra 2020-3-13
You can try using function “slice()”, refer to this link for more information : https://www.mathworks.com/help/matlab/ref/slice.html#d118e1325646. Also I found a similar question here : https://www.mathworks.com/matlabcentral/answers/488992-how-to-take-a-horizontal-slice-of-a-3d-surface-plot

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by