クロス積関数に問題があります。ピクセルごとに 2 つのベクトルの外積を取り、すべてのピクセルの結果を合計する必要があります。
i=1;
[h,w,d] = size(current_vec);
for pxRow = 1:h % fixed pixel row
for pxCol = 1:w % fixed pixel column
for pxsize = 1:d
for r = 1:h % row of distant pixel
for c = 1:w % column of distant pixel
for dpth = 1:d
bfield(c,r,dpth) = cross(current_vec(c,r,dpth),dist_vec(c,r,dpth)); % pythagoras theorem to get distance to each pixel % unit vector from x to s
end
end
end
Bfield(i) = {bfield}; % filling a cell array with results. read below
i = i+1;
end
end
end
??? Error using ==> cross at 37
A and B must have at least one dimension of length 3.
??? Error using ==> cross at 37
A and B must have at least one dimension of length 3.
Error in ==> MAC2 at 71
bfield(c,r,dpth) = cross(current_vec(c,r,dpth),dist_vec(c,r,dpth));
ただし、問題のあるベクトル current_vec および dist_vec は次のとおりです。
>> size(current_vec)
ans =
35 35 3
>> size(dist_vec)
ans =
35 35 3
私に関する限り、それらは外積で使用される基準を満たしています。なぜそうではないのですか?