Mostrar comentarios más antiguos
Hi
I wanted to plot 3D waterfall of XRD measurements but even after reading past answeres on the subject I don't succeed..
I have 4 sets of (x,y) as follows:
(Sample A(:,1),y1) % x values are the import of the 1st column from the measurement file that contains many columns but I just need the 1st
(Sample B(:,1),y2)
(Sample C(:,1),y3)
(Sample D(:,1),y4)
the 2D plot looks like this:

How to I make it looks like this?

So far I have:
[x,y]=meshgrid(Sample A(:,1),y1, Sample B(:,1),y2, Sample C(:,1),y3, Sample D(:,1),y4);
waterfall(x,y,z);
not sure what Z needs to be....
How can I continue?
Respuestas (1)
Simon Chan
el 5 de Jul. de 2022
Let's see function plot3 can satisfy your requirement or not.
figure;
ax = gca;
hold(ax,'on');
plot3(ax,SampleA(:,1),repelem(1,1,length(SampleA(:,1))),y1);
plot3(ax,SampleB(:,1),repelem(2,1,length(SampleB(:,1))),y2);
plot3(ax,SampleC(:,1),repelem(3,1,length(SampleC(:,1))),y3);
plot3(ax,SampleD(:,1),repelem(4,1,length(SampleD(:,1))),y4);
hold(ax,'off');
xlabel(ax,'2theta(degrees)');
zlabel(ax,'Intensity (a.u.)');
ylabel(ax,'');
ax.YTickLabel={'(a)','(b)','(c)','(d)'};
6 comentarios
mor levi
el 5 de Jul. de 2022
Simon Chan
el 5 de Jul. de 2022
Is it possible to attach your data or part of your data?
mor levi
el 5 de Jul. de 2022
Simon Chan
el 5 de Jul. de 2022
I did Sample A and C for you.
For Sample B and D, the number of data are not consistent.
Sample B and D has 9501 and 8501 data, but y2 nad y4 has 9500 and 8508 data respectively. So you need to correct them first.

clear; clc;
SampleA = readmatrix('SampleA-1st colum.xlsx');
y1 = readmatrix('y1.xlsx');
SampleC = readmatrix('SampleC-1st colum.xlsx');
y3 = readmatrix('y3.xlsx');
figure;
ax = gca;
plot3(ax,SampleA,repelem(1,1,length(SampleA)),y1);
hold(ax,'on');
plot3(ax,SampleC,repelem(2,1,length(SampleC)),y3);
hold(ax,'off');
xlabel(ax,'2theta(degrees)');
zlabel(ax,'Intensity (a.u.)');
ylabel(ax,'');
grid(ax,'on');
ax.YTick = [1 2];
ax.YTickLabel={'(a)','(c)'};
mor levi
el 5 de Jul. de 2022
Simon Chan
el 5 de Jul. de 2022
Yes, they should be same length.
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
