ping elements in an array? trying to trick it by putting it all on one line did not seem to work, sadly ;(
The first line takes no time since the 2 arrays are identical and MATLAB only does lazy copy or copy on write (see blogs on memory to learn more about this). Once an element is changing, MATLAB makes a full copy of the original array to be sure it doesn’t get modified improperly.
Again, the best way to drop elements is to create the new array and fill it, you’re 3rd way – only the copy needed for the output is created in addition to the original, I believe. I don’t think you can do better than that.
interesting. ok, i guess i’ll have to live with that ;)
thanks for your help…
hi every body
How to find the position of a matrix element…
Check out the functions find and ismember.
i have red this post, but didn’t find what I was looking for. Is there a easy way to make a logical matrix from subscript indices like the function find does but the other way round. Under method number 2 in your post you gave a small example what happens when you use subscripts to address the selected elements of a matrix. You get the full matrix back and not only the selected elements. I think the easiest way would be a logical to adress and get back only the selected elements. Using the function sub2ind is too much bother in my opinion.
As far as I know, there is not a simple 1-liner to go from subscripts to logicals without using sub2ind. Sorry you don’t care for that solution.
wasnt aware of this before, solved a bug i had been working on for two days already.