Concept of the null operator question
Afficher commentaires plus anciens
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 commentaires
the cyclist
le 4 Mar 2021
Modifié(e) : the cyclist
le 4 Mar 2021
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
le 5 Mar 2021
"...does that make the matrix now look like [1,2,4,5]?"
Yes.
Réponse acceptée
Plus de réponses (1)
Prudhvi Peddagoni
le 8 Mar 2021
0 votes
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!