Why do I get this error? If i do it in the command window it seems to be possible
Show older comments
Hi everybody, I have a similar problem and I have absolutely no clue where my mistake is. I get the same error but I don´t see why. I am a beginner at Matlab from germany sitting on my bachelor thesis. WIthin the project my goal is to check whether the point is sitting in a bounding box. Therefor I check the first box, which is described by the 8 Points on the Matrix M, with all the 8 points of my component. I then move on to the next box and so on. However if I go into the second box, I get the following error:

This is my Code or at least the part I think is relevant:


Please help me as I said I´m just getting started, so it´s possible I misunderstood something completely.
Thanks a lot guys,
Johnny
7 Comments
Geoff Hayes
on 8 May 2020
Johnny - it's hard to tell from your code screen shot (attaching the m file is easier) but it looks like you have a for loop with
for huellkoper=1:2
M=M{huellkoper};
% etc.
end
Do you really mean to set M to some element of M? It could be that the error is firing on the second iteration when M is no longer a cell array... Should the assigned to variable be named something else?
for huellkoper=1:2
MSubset = M{huellkoper};
% etc.
end
Jonathan Babitsch
on 8 May 2020
Jonathan Babitsch
on 8 May 2020
Walter Roberson
on 9 May 2020
If we had your actual code instead of a picture of part of the code, we could more easily advise you. The part of the code you show does not use M after the M=M{huellkoerper} line.
Jonathan Babitsch
on 9 May 2020
Walter Roberson
on 9 May 2020
Your code does not use M after the M=M{huellkoerper}; line, so it is difficult to understand how M fits with the rest of your code.
My idea is now to create different Matrix M1,M2 and the use huellkoerper again to count it up in a for loop. But instead of having a cell array I am going to say if huellkoerper is 1 use M1, elseif 2 use M2 and so on
NO! Just use M{huellkoerper} in the part of your code that you want the appropriate matrix!
Jonathan Babitsch
on 9 May 2020
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!