Defining a 4d double
43 次查看(过去 30 天)
显示 更早的评论
I am trying to build a 4D matrix from a velocity time series so that I can use it as an input to another program. My wind field is a M*N matrix where M is the number of points on the square grid and N is the measurement time in seconds (sampling at 1 hz). I now want to build a 4D array following which should look like this
4D_matrix=[time(1*N) velocity(M*N) x_coord(M,1) y_coord(M,1)];
How do i write this?
Thank you, Ananth
5 个评论
回答(2 个)
Guillaume
2017-6-13
Well, you need 676^3 * 600^2 * 8 bytes ~= 890 TB of memory to store that many elements, regardless of the shape. Chances are you don't have a computer with that much memory (not even in the ballpark).
You need to rethink what you want to do. In particular, I would think that x_coord and y_coord correspond to the rows and columns of your velocity field, therefore it does not make sense to store them in additional dimensions of the same matrix (as that would wastefully repeat the same values).
0 个评论
Pawel Tokarczuk
2017-6-13
I think what you need is something like:
Velocity = zeros([NROWS, NCOLS, NTIMES], 'double');
[ X, Y ] = meshgrid(0:NCOLS-1, 0:NROWS-1);
XX = X0 + ScaleX*X;
YY = Y0 + ScaleY*Y;
T = double(0:NTIMES-1);
TT = T0 + ScaleT*Time;
Note the order of the indices (column-major in the first two dimensions, last index varies most slowly).
Those should be the basic data structures; now, you just need to use them appropriately.
IHTH
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!