Where is the Documentation for Indexing on the Left Hand Side of an Assignment?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I recently ran into something like this:
x = [1 2 3];
x([1 2 1]) = [10 20 30]
So it looks like the second index of 1 on the LHS takes precedence over the first. I hunted through the documentation (searching on "assignment" was particularly fruitless) and I couldn't find any documentation discussing how indexing works on the LHS of an assignment in general, much less the rule for this particular use case.
Can anyone link to relevant doc page(s)? I feel like I've seen this topic in the doc before, but for the life of me can't find it now.
2 Kommentare
Chris
am 12 Sep. 2022
Bearbeitet: Bruno Luong
am 12 Sep. 2022
I mean...
Slicing the array up with repeated elements makes sense on the right side, perhaps, but why would that happen on the left side? Matlab is probably just following the index order. Working through the array, it first sets x(1) to 10 (index 1), then ends by setting x(1) to 30 (index 3).
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!