Changing data from a list to a matrix
17 ビュー (過去 30 日間)
古いコメントを表示
I have a list of data, 4 columns representing independent variables and the 5th column representing the value f(w,x,y,z). Data exists for every value of the independent variable in the desired range, through interpolation.
Is there an efficient way to change this data into a 4-dimensional array? I am trying to use it as table data in a 4-D lookup table.
Thanks.
0 件のコメント
採用された回答
the cyclist
2022 年 6 月 21 日
Can we make a simplified example, to understand what you mean? Suppose you just have 3 columns of data, and your function is f(x,y).
The "list" (i.e. 2-D array) of data is something like,
list = [1 1 5;
1 2 7;
1 3 11;
2 1 13;
2 2 17;
2 3 19];
where the three columns are [x, y, f(x,y)]. Is that right?
And so the output in this case would be a 2-D array of size 2*3, which you get by doing
out = reshape(list(:,end),[3,2])
If all that is correct, then I think what you want is
out = reshape(list(:,end),[nz,ny,nx,nw])
where the n's are the counts of the number of elements in each dimension.
This solution makes assumptions about the fact that the original list is ordered in a certain way. The solution is more complicated if it is not.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!