Concept of the null operator question
Show older comments
This is more of a conceputal question that I need help with.
If I have say sampleMatrix=[1,2,3,4,5] and then I type the code sampleMatrix(3)=[], does that make the matrix now look like [1,2,4,5]?
I ask because I want to know if you do the previously mentioned null operator code, does that now make the third element 4, or is 4 still the fourth element?
Thank you and I apologize if it is confusing.
2 Comments
That syntax fully removes the element from the vector. What used to be a length-5 vector is now a length-4 vector. The number 4 is now the 3rd element of that vector,
sampleMatrix = [1 2 3 4 5];
sampleMatrix(3)=[];
idx = find(sampleMatrix==4)
Stephen23
on 5 Mar 2021
"...does that make the matrix now look like [1,2,4,5]?"
Yes.
Accepted Answer
More Answers (1)
Prudhvi Peddagoni
on 8 Mar 2021
0 votes
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!