adding vector to matrix to create tensor
조회 수: 10 (최근 30일)
이전 댓글 표시
Hi. I have a 10176X10176 matrix and a 10176X1 vector that I want to add to the matrix in order to create a 10176X10176X10176 tensor, without a for loop.
How should I go about that?
댓글 수: 0
채택된 답변
Dyuman Joshi
2023년 7월 24일
%Sample example
y = rand(12,12);
z = rand(12,1);
%Change the dimensions of z from mxnx1 to nx1xm
z0 = permute(z,[2 3 1]);
size(z0)
%Perform the addition
out = y + z0;
size(out)
댓글 수: 1
Steven Lord
2023년 7월 24일
This is a correct answer, but it probably won't work on the original question for practical reasons. Assuming the data is real double data:
numElements = 10176^3;
bytes = 8*numElements;
tb = bytes/(1000^4)
the result would require over 8 terabytes of contiguous memory to store.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!