Slice of a surface plot created by 2D data
51 views (last 30 days)
Show older comments
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.
I am tryging to do something like this: https://stackoverflow.com/questions/38342244/how-can-i-create-a-slice-of-a-surface-plot-to-create-a-line-matlab
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 Comment
Thiago Henrique Gomes Lobato
on 9 Feb 2020
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)
Answers (1)
Rajani Mishra
on 13 Mar 2020
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
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!