Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How do I add a colormap to a series of 3D lines?

1 回表示 (過去 30 日間)
Bruno Soares
Bruno Soares 2020 年 9 月 24 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello,
For a 3D plot I have:
U = 2:0.2:30;
f is a 1x20002 vector of frequencies
the Z axis is a 141x20002 matrix of values between 0 and 1.
An example figure of what I am trying to achieve is:
As you can see from the figure, there is a spectrum line for each U* and most of the frequencies are between 0-2.
Now, I can plot it using plot3 for my data just fine, please see the figure below:
However, I think the parula colormap for each U* line is quite nice. I have checked that it is not possible to do this with the plot3 function.
I have tried the surf function as well but there is something missing.
Would anyone please be able to instruct me on how could I do it?

回答 (1 件)

KSSV
KSSV 2020 年 9 月 24 日
Read about waterfall.
  7 件のコメント
KSSV
KSSV 2020 年 9 月 25 日
編集済み: KSSV 2020 年 9 月 25 日
Try scatter with marker style as squares. Share your data, let me try as well. Show your code which you have tried. That should be possible with waterfall too.
Bruno Soares
Bruno Soares 2020 年 9 月 25 日
編集済み: Bruno Soares 2020 年 9 月 25 日
Sure, please see the code below and data attached:
Fs=100;
spacing=1;
cut=20000; Tspan=0:0.01:600; Ured1=2:4:28;
L=length(Tspan(cut:end));
f = 2*pi*Fs*(0:(L/2))/L;
for ijj=1:length(Ured1)
p2=Y1(ijj,:);
p2=p2(:);
Y222 = fft(detrend(p2(cut:end),'constant'));
P21 = abs(Y222/L);
P11 = P21(1:L/2+1);
P11(2:end-1) = 2*P11(2:end-1);
ydft = Y222(1:L/2+1);
psd2 = (1/(Fs*L)) * abs(ydft).^2;
normalised(:,ijj) = (psd2-min(psd2))/(max(psd2)-min(psd2));
end
figure(16);clf;
set(gcf,'color','w');
MatrixUred1=ones(length(Ured1),length(f));
Matrixf=ones(length(Ured1),length(f));
for i=1:length(Ured1)
MatrixUred1(i,:)=MatrixUred1(i,:)*Ured1(i);
end
Matrixf=repmat(f,7,1);
% surf(MatrixUred1',Matrixf',normalised,...
% 'facecol','no',...
% 'edgecol','interp',...
% 'linew',2);
plot3(MatrixUred1',Matrixf',normalised,'k')
hold on
[M,I]=max(normalised);
a=I;
ylim([0 5]);xlim([2 30]);
xticks(2:4:30);yticks(0:5);zticks(0:0.1:1);

Community Treasure Hunt

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

Start Hunting!

Translated by