필터 지우기
필터 지우기

How to fix this error 'Error using xor Matrix dimensions must agree'?

조회 수: 2 (최근 30일)
waffle
waffle 2017년 4월 18일
댓글: Walter Roberson 2017년 11월 13일
Here is my code
  댓글 수: 5
waffle
waffle 2017년 4월 29일
편집: waffle 2017년 4월 29일
So what can I do to make the a9 size =215x550 same as a7?
Stephen23
Stephen23 2017년 4월 29일
편집: Stephen23 2017년 4월 30일
"So what can I do to make the a9 size =215x550 same as a7?"
This is up to you (the designer of that code): you could take a submatrix, interpolate, pad, permute, or perhaps something else. It depends on your data and your algorithm, which you have told us nothing about.

댓글을 달려면 로그인하십시오.

답변 (4개)

Roger Stafford
Roger Stafford 2017년 4월 27일
Your a1 and a3 arrays would have different numbers of columns unless the ‘c’ value is exactly half of size(BW,2), so an ‘xor’ operation on them would be undefined:
a1=BW(:,1:c);
a2=BW(:,c+1:end);
.......
a3=fliplr(a2);
a4=xor(a1,a3);
  댓글 수: 4
waffle
waffle 2017년 4월 29일
How to make size a7 and a9 size same?
Roger Stafford
Roger Stafford 2017년 4월 30일
That isn’t the right question to ask. You should be asking what the difficulty is in your prior code that has caused a7 and a9 to be different in sizes at that point. That is what needs to be fixed and only you can do that because only you know what it is you are attempting to accomplish with your code.

댓글을 달려면 로그인하십시오.


Jan
Jan 2017년 4월 19일
There are several xor commands in your code. The complete error message shows you, which command is failing. You could use the debugger also: Type this in the command window:
dbstop if error
Then run the code again. What Matlab stops at the error, you can inspect the sizes of the arguments. It is nearly impossible for the readers to fix your code, because you did not insert useful comments in the code. Then we have to guess the intention of the code and all information we have is the failing program. So it is up to you to find out, how to fix the problems.

Image Analyst
Image Analyst 2017년 4월 30일
I could fix your code if you had attached SSM33_orig.jpg. It's not running for a general demo image such as peppers.png and I don't get the error message you get because it doesn't get that far. I get this:
Expected one output from a curly brace or dot indexing expression, but there were 9 results.
Error in test2 (line 36)
c = stats.Centroid(:,1);
Please attach your image if you want people to run your code and help you fix it.
  댓글 수: 8
waffle
waffle 2017년 5월 3일
ok tq.how can i find xCenter? what xCenter means and represent for?
Walter Roberson
Walter Roberson 2017년 5월 3일
xCenter = reg.Centroid(1,1) -- that is, it is the x coordinate of the centroid.

댓글을 달려면 로그인하십시오.


Yasir Ghafoor
Yasir Ghafoor 2017년 11월 13일

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by