"Arrays have incompatible sizes for this operation" error

As you can see in the attached photo, all of my arrays have the same size (3600 x 3601). So, I don't understand how I keep getting this error.

답변 (1개)

the cyclist
the cyclist 2024년 6월 3일

0 개 추천

It's difficult to know for sure, but I'm guessing those are the variables as they exist in the workspace, outside the function.
Inside the function, you are loading the variables. Are you sure they are all the same size inside of those *.MAT files? Try putting a breakpoint at line 11 of your code, and see what the variable sizes are there.
Can you upload the files here (and your actual code, not a screenshot), so we can try?

댓글 수: 7

It's a really large code with several different files involved. Is it possible to schedule a call with someone where I can share my screen?
Before the line
Binary_Sum = Binary_Summary| ...
insert the lines
size(Binary_Summary)
size(Binary_Pitch)
size(Binary_SidePitch)
size(Binary_Clearance)
size(Binary_App)
size(Binary_Dep)
The output of all the six commands should be the same, namely [h,w].
You could contact Technical Support directly using this link. But before you do that, could you add one line of code to your function and show us what it displays when you run your code? Add this line between lines 10 and 11, right before the line where the error occurs.
whos
Copy and paste that whos output into a comment in this discussion. I suspect that at least one of the variables (BinarySummary would be my guess) is going to be a different size, and I'm guessing its size will be [3601 3600] instead of [3600 3601]
Yes, I tried it and Binary Summary is [3601 3602] so it's the one that doesn't match
We don't know where those variables came from. So we don't know why GeoTifData has different values for its Height and Width properties or fields than you expected.
Those values sounded familiar, though. Searching I found your other question. It sounds like you manually changed those values. In that case I agree with the comment by @Stephen23 on that post: you're likely going to need to resample your data, not just change those values and hope everything automagically becomes the right size. Drawing an extra 0 on a $1 bill with a marker doesn't make it a $10 bill.
Okay, but I don't know how to resample my data where the height and width will be changed to the correct values. I did not create the array manually. My array (the one with the off dimensions) was created from data from a GeoTiff file that I am not able to change.
I don't know. Maybe it's a lost cause.
Take a look at the imresize function and/or this example from the interpolation documentation. If you're using Mapping Toolbox there may be functions you can use in that product as well, ones that are designed specifically for working with geographic data. Maybe georesize?

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

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

태그

질문:

2024년 6월 3일

댓글:

2024년 6월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by