Counting the number of elements in matlab -
i new matlab. suppose have vector x = [1 1 1 1 1 1 0 0 1 0]. want calculate total number of elements in vector , number of non 0 elements in vector. come ratio of both numbers. searching in matlab help. how count of elements, till didn't luck. if provide me help, of great help. in advance.
you can number of elements numel(x)
.
you can number of non-zeros sum(x ~= 0)
.
so ratio 1 divided other.
Comments
Post a Comment