Count size of matrix without size function in matlab

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 5K views
hsong9
Messages
71
Reaction score
1
I need to keep track of the size of the matrix myself.
This means I can't use "size" function.
Is it possible?
For example,

A is a 5 x 5 matrix. I need to create a vector x=[0,0,0,0,0].
It should be just
x = zeros(size(A,1),1); %or length(A)

but I need to check the size of A matrix without size function.

Could anyone give me hints?

Thank you
 
Physics news on Phys.org
Wouldn't A(1, :)*0 or A(:, 1)*0 work?
 
INPUT
A= zeros(5,6) % Just as an Example
Cols=length(A) % Returns # of columns in A

OUTPUT
A= [0 0 0 0 0 0; 0 0 0 0 0 0; 0 0 0 0 0 0; 0 0 0 0 0 0; 0 0 0 0 0 0]
Cols=6

does that help?