MATLAB Answers

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

29 views (last 30 days)
Bruno Soares
Bruno Soares on 24 Sep 2020 at 17:39
Edited: Bruno Soares on 25 Sep 2020 at 11:01
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?

  0 Comments

Sign in to comment.

Answers (1)

KSSV
KSSV on 24 Sep 2020 at 17:49
Read about waterfall.

  7 Comments

Show 4 older comments
Bruno Soares
Bruno Soares on 25 Sep 2020 at 10:14
I divided the step by 2 and got the following:
KSSV
KSSV on 25 Sep 2020 at 10:19
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 on 25 Sep 2020 at 10:38
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);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by