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!