Array dimensions must match for binary array op.
조회 수: 6 (최근 30일)
이전 댓글 표시
How to map these array to perform the function as, size of array A and B
size(A)
ans =
256 256 4
>> size(d)
ans =
1 1
inv = (eye(d) + 2*tau*gamma1*A)^(-1);
댓글 수: 0
답변 (1개)
Deepak
2025년 6월 5일
I understand that you are trying to perform a matrix operation involving arrays A and d, specifically computing an inverse expression like:
inv = (eye(d) + 2*tau*gamma1*A)^(-1);
However, your array A has size 256×256×4 and d is 1×1, which suggests a dimension mismatch — eye(d) creates a 1×1 identity matrix, but you likely want an identity matrix matching the first two dimensions of A.
To fix the dimension mismatch and perform the intended operation for each 2D slice of A, you can loop through the third dimension and compute the inverse per slice:
tau = 0.1; % example scalar
gamma1 = 0.5; % example scalar
A = rand(256,256,4); % example A
inv_result = zeros(256,256,4);
for k = 1:size(A,3)
inv_result(:,:,k) = inv(eye(256) + 2*tau*gamma1*A(:,:,k));
end
This way, you correctly apply the inverse operation to each 256×256 matrix slice in A.
Please find attached the documentation of functions used for reference:
I hope this hleps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!