3D plot from tables in timeline
显示 更早的评论
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 个评论
Walter Roberson
2020-6-22
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
2020-6-22
For the 3d plot, what are the x, y and z axis ?
Eva R
2020-6-22
Mohammad Sami
2020-6-23
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
2020-6-23
Mohammad Sami
2020-6-24
编辑:Mohammad Sami
2020-6-24
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
2020-6-24
采纳的回答
更多回答(1 个)
darova
2020-6-24
0 个投票
Can you interpolate your data to make it equal size? Concantenate it and use surf
类别
在 帮助中心 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
