Array dimensions must match for binary array op.
11 ビュー (過去 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!