Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

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

1 visualizzazione (ultimi 30 giorni)
Bruno Soares
Bruno Soares il 24 Set 2020
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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?

Risposte (1)

KSSV
KSSV il 24 Set 2020
Read about waterfall.
  7 Commenti
KSSV
KSSV il 25 Set 2020
Modificato: KSSV il 25 Set 2020
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 il 25 Set 2020
Modificato: Bruno Soares il 25 Set 2020
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