[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem about returning a matrix
From: |
Carlo de Falco |
Subject: |
Re: problem about returning a matrix |
Date: |
Tue, 7 Apr 2009 15:32:47 +0200 |
On 7 Apr 2009, at 13:54, ozalpi wrote:
Hi, we want to develop a function that returns a matrix but we
couldn't be
able to convert this matrix or more simply a list to an
octave_value_list to
return the result. Only the first element of the matrix is seen from
octave.
Can anyone help us about this problem we have?
Our code segment is:
#include <octave/oct.h>
...
...
DEFUN_DLD(...)
{
octave_value_list retval;
for(int i = 0; i < row1; i++)
{
for(int j = 0; j < column1; j++)
{
out >> x;
retval(i*column1 + j)=octave_value(x);
}
}
return retval;
}
this function, as it stands, returns each element of the matrix as a
separate variable..
I guess what you want to do is rather something like
#include <octave/oct.h>
...
...
DEFUN_DLD(...)
{
Matrix A;
for(int i = 0; i < row1; i++)
{
for(int j = 0; j < column1; j++)
{
out >> x;
A(i*column1 + j)=x;
}
}
return octave_value(A);
}
c.