Reading data from a variable matrix

  • Follow


Is it possible to read through the data in a variable matrix and allocate it to memory? Much like what would be done when reading a file? I need to read all of the values of a 1x1900 matrix, then count how many times each number from 1-120 is in the matrix. 
0
Reply see.me.trot (7) 6/15/2012 8:05:09 PM

On 6/15/2012 3:05 PM, Ellen wrote:
> Is it possible to read through the data in a variable matrix and
> allocate it to memory? Much like what would be done when reading a file?
> I need to read all of the values of a 1x1900 matrix, then count how many
> times each number from 1-120 is in the matrix.

doc histc

--

0
Reply none1568 (6639) 6/15/2012 9:00:27 PM


On 6/15/2012 3:05 PM, Ellen wrote:
> Is it possible to read through the data in a variable matrix and allocate
>it to memory? Much like what would be done when reading a file? I need
>to read all of the values of a 1x1900 matrix, then count how many
>times each number from 1-120 is in the matrix.

I am not sure I understand. When you write

A=rand(5,1)

A is now in memory, it is not on disk?

You can iterate over it, since it is in memory using a 'for'.

But you do not really need to. You can use let Matlab
do the hard work. You sit back and relax

example

--------------------
EDU>> A
     0.8147
     0.9058
     0.1270
     0.9134
     0.6324

EDU>>  A( (0 <= A) & (A< 0.5) )

     0.1270
--------------------

--Nasser






0
Reply Nasser 6/15/2012 9:13:56 PM

On 6/15/2012 4:00 PM, dpb wrote:
> On 6/15/2012 3:05 PM, Ellen wrote:
>> Is it possible to read through the data in a variable matrix and
>> allocate it to memory? Much like what would be done when reading a file?
>> I need to read all of the values of a 1x1900 matrix, then count how many
>> times each number from 1-120 is in the matrix.
>
> doc histc
>

Small example...

 >> x=fix(10*rand(1,10))
x =
      2     8     2     8     9     2     2     0     0     6
 >> min(x):max(x)
ans =
      0     1     2     3     4     5     6     7     8     9
 >> histc(x,[min(x):max(x)])
ans =
      2     0     4     0     0     0     1     0     2     1
 >>

--

0
Reply none1568 (6639) 6/15/2012 9:17:53 PM

3 Replies
36 Views

(page loaded in 0.074 seconds)

Similiar Articles:













7/13/2012 4:30:52 PM


Reply: