help-octave
[Top][All Lists]
Advanced

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

Problem with reading lists


From: Marcus Vinicius Eiffle Duarte
Subject: Problem with reading lists
Date: Tue, 8 Mar 2005 14:26:28 -0300

Hey, folks!

I just discovered that textread returns lists, instead of cell arrays.
I didn't find some kind of list2cell function. Is there any built-in
or m-function to convert one to another.
I tried the code

        function cellvar = list2cell( listvar )
        elements = length( listvar );
        cellvar = cell( elements, 1 );
        for aux = 1 : size( listvar, 1 )
                cellvar{ aux } = listvar( aux );
        end

However, when I try 
        x = list(1,2,3,4); 
        xx = list2cell(x);

Octave gives an error and closes.

Weirdly enough, when I try the code

        function cellvar = list2cell( listvar )
        elements = length( listvar );
        cellvar = cell( elements, 1 );
        for aux = 1 : size( listvar, 1 )
                tmp = listvar( aux );
                cellvar{ aux } = tmp;
        end

and run again 
        x = list(1,2,3,4); xx = list2cell(x);

I get the same error. I introduced a "pause" between the lines"tmp =
listvar( aux );" and "cellvar{ aux } = tmp;", and Octave immediately
close before pausing.

I tried onde again, running from octave's prompt
        octave:1> x=list(1,2,3,4);for kk=1:length(x),xx{k}=x(kk),end

and Octave exited again. It also exits if I run
        octave:1> x=list(1,2,3,4);for kk=1:length(x),xx(k)=x(kk),end

And it also exits when running
        octave:1> x=list(1,2,3,4); xx=x(1); 

I can run normally
        octave:1> x=list(1,2,3,4); xx=x;
But if I add to the former code the line (after copying the list)
        octave:2> xx(2)=x(2)
Octave also exits.

I am running Octave 2.1.57 + Octave-Forge 20041116 under Fedora Core 3.
Am I doing something wrong and tremendously stupid here?

Thanks in advance,

Marcus Vinicius Eiffle Duarte



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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