How do I plot xy plots into one 3D plot?

2 visualizaciones (últimos 30 días)
Eva R
Eva R el 30 de Jun. de 2020
Comentada: Eva R el 3 de Jul. de 2020
Hello dear community!
I am trying to make a 3D plot from my data. Each dataset includes depth measurements and absorbance measurements, which I usually plot in 2D as x = depth and y = absorbance. I saved all datasets as equal-size matrices with depth in the first column and absorbance in the second. There are multiple datasets per year, which are more or less evenly spaced (40 datasets per year), so I would like to combine them all in one plot, preferably a surface plot. As an additional variable I thought I could just use a vector (0:1:40) to distribute my depth/absorbance values according to that.
All tutorials that I found include some functions for z, but I don't have any, so I am not sure how to manage this.
Your help is really appreciated, thanks!
Eva
  8 comentarios
Johannes Fischer
Johannes Fischer el 1 de Jul. de 2020
Sry, my mistake, the instructions on how to assign X, Y and Z should work with scatter3, but not surf.
For surf, all matrices must be of the same size since you want to have depth and time represented in the x y plane, the matrix size (in your example) for X and Y would need to be 3x1001 (assuming that the data in the files is 1001x2. Thus Z must also be 3x1001.
In general, try to avoid enumerating your variable names. This makes looping over data much easier
filenames = {'01_24_2008_for_3D_analysis', ...
'02_05_2008_for_3D_analysis', ...
'02_19_2008_for_3D_analysis'};
for ii = 1:numel(filenames)
%data = readmatrix(filenames{ii});
data = [(1:5)+rand(1, 5); ii*ones(1, 5)+rand(1, 5)]';
depths(:, ii) = data(:, 1);
crypto(:, ii) = data(:, 2);
end
t = repmat(1:numel(filenames), [size(depths,1) 1]);
figure
surf(depths, t, crypto)
Eva R
Eva R el 3 de Jul. de 2020
Thanks so much Johannes, works like a charm!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by