Count size of matrix without size function in matlab

  • MATLAB
  • Thread starter hsong9
  • Start date
  • #1
80
1

Main Question or Discussion Point

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
 

Answers and Replies

  • #2
131
0
Wouldn't A(1, :)*0 or A(:, 1)*0 work?
 
  • #3
100
0
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?
 

Related Threads on Count size of matrix without size function in matlab

  • Last Post
Replies
4
Views
19K
  • Last Post
Replies
1
Views
550
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
10
Views
82K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
1
Views
2K
Top