How to fix "Error using == Arrays have incompatible sizes for this operation." in this code?
古いコメントを表示
Hi, I am writing the following code:
for k = 1 : length(theFiles) % files are alreaady defined in original code
p=1;
t=1;
for q=1:43 % there are 43 inputs for arr
c=corr2(B0,mask);
arr(p)=abs(c);
if(arr(p)<1)
if(arr(p)>0.85)
cor(t)=arr(p);
t=t+1;
end
end
p=p+1;
end %end of q loop
mx=max(cor); %conditioned arr
ixa=find(arr==mx,1) %find the location for which mx matches arr value the first instance
But when run, the result shows following:
Error using ==
Arrays have incompatible sizes for this operation.
Error in Untitled12 (line 264)
ixa=find(arr==mx,1);
It is noteworthy that, the error shows only for certain image inputs. For other inputs, the code works fine.
How can I fix it?
3 件のコメント
kanika bhalla
2021 年 7 月 7 日
@Tawsif Mostafiz Can you add those images on which your code gives error so that we can try and check what is a problem?
Thiripura Sundari
2025 年 3 月 1 日
Arrays have incompatible sizes for this operation.
Error in guna1 (line 32)
RHS = (theta(2:end-1,j)/dt) + Ec*((diff(u(:,j))./dy).^2) - Q*0.5*(theta(3:end,j)-theta(2:end-1,j));
give answer
Walter Roberson
2025 年 3 月 1 日
We do not know the size of dt
We do not know the size of Ec
We do not know the size of dy
We do not know the size of Q
We do not know for sure that j is scalar.
We do not know the size(theta,1)-2 is the same as size(u,1)-1 . This is the most likely culprit. If j is scalar then size(theta(2:end-1,j),1) is N-2 (where theta is size(theta,1)) and size(diff(u(:,j)) is M-1 where M = size(u,1). If size(theta,1) is the same as size(u,1) then you would would have a mismatch of sizes, N-2 compared to N-1
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!