Matrix split in vector
Show older comments
Hello everyone! I need a little help, I'm at the beginning and I would like to create a function that receives a matrix with positive elements (0 included) and returns in a vector line by line the elements of the matrix without zeros. A little help, please?
ex: A = [1 2 0 3; 0 0 4 5; 6 0 7 8]
newA= [1, 2, 3, 4, 5, 6, 7, 8]
Accepted Answer
More Answers (1)
iwant = A(A>0)
If you want in the order you have given.
A = A' ;
iwant = A(A>0)
Categories
Find more on Entering Commands 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!