[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 2.1.33 changelogs/cells
From: |
Gabor Zoltan Csejtey |
Subject: |
Re: 2.1.33 changelogs/cells |
Date: |
Thu, 22 Feb 2001 16:36:13 +0100 (MET) |
Hi,
There was an untested code of cellget on this list earlier:
Some code from ov-list.cc was copied and modified to ov-cell.cc in the
source directory of octave.
Question: how to put this function into the octave info file?
Here's what you need to put in the ov-cell.cc file.
/*
Date: Thu, 15 Feb 2001 17:20:56 +0000
From: Paul Kienzle <address@hidden>
Subject: Re: extract from cell?
Sender: address@hidden
You could use the following untested function based on nth from ov-list.cc:
- Paul
*/
DEFUN (cellget, args, ,
"-*- texinfo -*-\n\
@deftypefn {Built-in Function} {} cellget (@var{cell}, @var{i}, @var{j})\n\
Return the @var{i,j}-th element of @var{cell}.\n\
@end deftypefn")
{
octave_value retval;
int i=-1,j=-1;
if (args.length() < 2 || args.length() > 3)
{
print_usage ("cellget");
return retval;
}
i = args(1).int_value (true);
if (error_state || i < 1)
{
error ("cellget: second argument must be a positive integer");
return retval;
}
if (args.length() == 3)
{
j = args(2).int_value (true);
if (error_state || j < 1)
{
error ("cellget: third argument must be a positive integer");
return retval;
}
}
Cell cell = args(0).cell_value ();
if (! error_state)
{
int nr = cell.rows();
int nc = cell.columns();
if (j == -1)
if (nr == 1)
if (i <= nc)
retval = cell(0,i-1);
else
error ("cellget: index = %d out of range", i);
else if (nc == 1)
if (i <= nr)
retval = cell(i-1,0);
else
error ("cellget: index = %d out of range", i);
else
error ("cellget: single index not valid for 2-D cell array");
else if (i <= nr && j <= nc)
retval = cell(i-1, j-1);
else
error ("cellget: index = %d,%d out of range", i, j);
}
else
error ("cellget: first argument must be a cell");
return retval;
}
Gabor
Date: Thu, 22 Feb 2001 16:13:10 +0100
From: Daniel Heiserer <address@hidden>
Hi,
is there some way to find out what has changed from 2.1.33 to
2.1.33 without examining the diff file?
Can 2.1.33 return the content of a cell correctly?
If not what has to be done?
I had the problem that I was not able to extract elements from
a cell into a matrix again.
e.g. a={rand(3)};
c=a{1};
c =
{
[1,1] =
0.15108 0.67447 0.70927 0.93837
0.20088 0.30963 0.26579 0.68902
0.78126 0.19126 0.25733 0.74309
0.53532 0.61626 0.59922 0.21876
}
--
Mit freundlichen Gruessen
Daniel Heiserer
--------------------------------------------------------------
Dipl.-Phys. Daniel Heiserer, BMW AG, Knorrstrasse 147, 80788 Muenchen
Abteilung EK-20
Tel.: 089-382-21187, Fax.: 089-382-42820
mailto:address@hidden
Lageplan Standort FIZ:
http://www.stadtplandienst.de/query?ORT=M&STR=Knorrstr.&HNR=147
-------------------------------------------------------------
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
-------------------------------------------------------------