Concept of the null operator question
Mostrar comentarios más antiguos
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 comentarios
the cyclist
el 4 de Mzo. de 2021
Editada: the cyclist
el 4 de Mzo. de 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
el 5 de Mzo. de 2021
"...does that make the matrix now look like [1,2,4,5]?"
Yes.
Respuesta aceptada
Más respuestas (1)
Prudhvi Peddagoni
el 8 de Mzo. de 2021
0 votos
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!