help-octave
[Top][All Lists]
Advanced

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

Convert double to octave_value for assignment to column vector


From: babelproofreader
Subject: Convert double to octave_value for assignment to column vector
Date: Tue, 1 Jun 2010 17:26:14 -0700 (PDT)

I want to allocate the result of a feval function call to a column vector in
the code below

#include <octave/oct.h>
#include <octave/dColVector.h>
#include <octave/parse.h> 

DEFUN_DLD (rm_compile_1, args, , "Input is a column vector, output is median
vector. This is a test of compiling Octave median function")
{
octave_value_list retval;

 ColumnVector rm_compile_1_input = args(0).column_vector_value ();
 ColumnVector rm_compile_1_output = args(0).column_vector_value ();
 octave_value input_median; // declare an octave value to hold output of
feval call to Octave median function 

 input_median = feval ( "median", octave_value (rm_compile_1_input) );

 for (octave_idx_type ii (0); ii < args(0).length (); ii++) // loop to fill
output vector with median value
     {
     rm_compile_1_output(ii) = input_median;
     }

retval = rm_compile_1_output;

return retval;
}

but on compiling there is an error message
rm_compile_1.cc:17: error: cannot convert ‘octave_value’ to ‘double’ in
assignment

How do I convert the returned value from the feval call to an octave type
that can then be assigned to the column vector in the loop?
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/Convert-double-to-octave-value-for-assignment-to-column-vector-tp2239451p2239451.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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