Error: A(:) = B, the number of elements in A and B must be the same.
2 views (last 30 days)
Show older comments
Ammar Babikir
on 11 Feb 2018
Commented: Ammar Babikir
on 11 Feb 2018
Hi everyone, I can't seem to understand why this piece of code:
while( empty_cond ~= 0 && myStack.peek()~= goal)
%pop first index from the stack
i = myStack.pop();
%if node at i has not been visited
if ( visited(i) == 0)
%mark it as visited
visited(i) = 1;
neighbors(i) = sense_maze(i, data);
end
I end up getting this error:
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in RUNME (line 55) neighbors(i) = sense_maze(i, data);
I also attached a picture of the workspace.
2 Comments
Image Analyst
on 11 Feb 2018
How are we to know which line threw that error? You forgot to include the complete error, which includes the line number and line of code. Please include ALL THE RED TEXT.
Accepted Answer
Image Analyst
on 11 Feb 2018
Two problems. First, sense_maze does not show up in your workspace so the code does not know about it at that point. Secondly data is a structure, not an integer starting from 1. So you need to get the integer from the structure.
3 Comments
Image Analyst
on 11 Feb 2018
OK, if sense_maze is a function in a separate m-file on the search path, then that is okay. However the error message is acting like sense_maze is an array. Please attach that m-file so I can see what kind of input is expected for its second argument.
data is a structure, not a number - this is what the error message is telling you. So it has fields, like a, b, and myNumber or whatever. Save data to an mat file and attach that also.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!