3D plot from tables in timeline
Afficher commentaires plus anciens
Hello!
I am trying to plot my data (contains water depth and absorbance at 2 different wavelengths for each measured depth) into a 3D plot. I have pre-procressed the data so all datasets (approx 100/year) contain the same variables and the same number of columns in a table, but the number of rows sometimes varies (I don't have equal numbers of depth measurements). I would like to plot my data into a 3D plot so all data from one year can be in one surface-3D plot to visualize the development over one year.
I have tried putting all my data into a 3D matrix and then plotting it, but I have multiple problems: I tried using table2array and then creating a 3D array, but the different row numbers keep giving me problems. I tried using zeros() and then an array overlay with all smaller tables, but 1) I don't know which one is my biggest dataset and 2) I don't want to do this manually/ I would like to use some kind of loop to first fill the 'empty' rows with zeros and then put everything together in one 3D matrix and then plot it into a 3D plot.
Can anybody help here?
Thanks!! :)
7 commentaires
Walter Roberson
le 22 Juin 2020
Is it the case that when you have more rows, that the additional rows are in a fixed progression along some length axes? For example, all row #17 that exist are the same depth as each other, all row #18 that exist are at the same depth as each other and that is greater than for row #17 ?
If you put the arrays into a cell array as you read / preprocess them, then you can
cols = size(TheCell{1},2);
row_sizes = cellfun(@(M) size(M,1), TheCell);
max_rows = max(row_sizes);
PaddedCells = arrayfun(@(M, R) [M{1}; nan(R-max_rows, cols)], TheCell, row_sizes, 'uniform', 0);
Array3D = cat(3, PaddedCells{:});
Mohammad Sami
le 22 Juin 2020
For the 3d plot, what are the x, y and z axis ?
Eva R
le 22 Juin 2020
Mohammad Sami
le 23 Juin 2020
What if you just scaled your z axis between 0 and 1 (or some other values) ? E.g 0 will be 1st January and 1 would be 31st December.
You would then be able to handle variable number of rows.
Eva R
le 23 Juin 2020
Mohammad Sami
le 24 Juin 2020
Modifié(e) : Mohammad Sami
le 24 Juin 2020
What is the size of the data you are loading. What do the rows and columns correspond to ?
For plot3, the X,Y,Z values must satisy either of these properties for the function to work
Vector of same length or
Specify at least one of X, Y, or Z as a matrix, and the others as vectors. Each of X, Y, and Z must have at least one dimension that is same size. For best results, specify all vectors of the same shape and all matrices of the same shape.
Eva R
le 24 Juin 2020
Réponse acceptée
Plus de réponses (1)
Catégories
En savoir plus sur Interpolation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
