help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help : how to load only a part of a matrix in octave


From: Jordi Gutiérrez Hermoso
Subject: Re: help : how to load only a part of a matrix in octave
Date: Mon, 4 Jun 2012 09:55:20 -0400

Tharaka, please avoid top-posting if possible.

    http://en.wikipedia.org/wiki/Top_posting#Top-posting

On 4 June 2012 09:32, tharaka weheragoda <address@hidden>
wrote:
> On Sun, Jun 3, 2012 at 12:47 PM, Markus Bergholz <address@hidden> wrote:
>>
>> On Sun, Jun 3, 2012 at 7:32 AM, tharaka weheragoda
>> <address@hidden> wrote:

>> >   I have a huge matrix and a vector to multiply.Is there any way
>> > to load only a part of this huge matrix at a time when doing
>> > multiplication?
>>
>>
>> m(:,10:20) takes just columns 10 to 20 of you matrix.
>> m(5:10,:) takes just row 5 to 10 of you matrix
>> you can combine it too
>> m(2:8,12:15) takes row 2 to 8 and column 12 to 15.
>>
>> but i don't know if this is what you want?

> matrix is 32000*32000 and vector is 1*32000 .what i need is load
> only first 1000 rows of the matrix first and second 1000 rows next
> and so on.But the thing is i don't know how to load only that part
> instead of loading whole matrix.

You can use fread's size and skip arguments to read parts of a matrix.
So something like this might work:

    f = fopen("what_is_the.mat");
    for i = 1:32
      m = fread(f, [i*1e3, 3.2e4], "double", (i-1)*1e3);
      ## now do whatever you want with m
    endfor

HTH,
- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]