|
From: | Nicholas Jankowski |
Subject: | Re: Octave C++ |
Date: | Fri, 27 Oct 2017 13:15:53 -0400 |
Hello, I want to pass to the external function in the *.m-file 4 parameters that I load from an external *.mat-file, you can tell how to do it?
#include <QCoreApplication>
//
#include <iostream>
#include <string>
//
#include <oct.h>
#include <octave.h>
#include <parse.h>
#include <toplev.h>
#include <interpreter.h>
#include <builtin-defun-decls.h>
#include <Cell.h>
#include <Matrix.h>
#include <cmd-edit.h>
#include <cmd-hist.h>
#include <file-ops.h>
#include <file-stat.h>
#include <oct-env.h>
#include <oct-time.h>
#include <quit.h>
#include <comment-list.h>
#include <defaults.h>
#include <dirfns.h>
#include <dynamic-ld.h>
#include <error.h>
#include <input.h>
#include <lex.h>
#include <load-path.h>
#include <oct-hist.h>
#include <oct-map.h>
#include <ov-fcn-handle.h>
#include <ov-usr-fcn.h>
#include <ov-null-mat.h>
#include <toplev.h>
#include <pager.h>
#include <parse.h>
#include <pt-all.h>
#include <pt-eval.h>
#include <symtab.h>
#include <token.h>
#include <unwind-prot.h>
#include <utils.h>
#include <variables.h>
void runscript(const std::string &file)
{
int parse_status = 0;
eval_string(file, false, parse_status);
//eval_string(file, false, parse_status, 0);
}
//---------------------------------------------------------- --
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
string_vector octave_argv (2);
octave_argv(0) = "embedded";
octave_argv(1) = "-q";
octave::embedded_application app_oct(2, octave_argv.c_str_vec());
app_oct.execute();
load_fcn_from_file("Emulate.m", "", "", "", "Emulate", true);
//source_file("Emulate.m");
// call the function with an argument
octave_value_list args;
args(0) = "data.mat";
args(1) = "a";
feval("load", args, 0);
runscript("load data.mat");
octave_value trainData = get_top_level_value("trainData", false);
octave_value trainLabel = get_top_level_value("trainLabel", false);
octave_value testData = get_top_level_value("testData", false);
octave_value testLabel = get_top_level_value("testLabel", false);
octave_value_list in;
in(0) = trainData;
in(2) = trainLabel;
in(3) = testData;
in(4) = testLabel;
octave_value_list result = feval("Emulate");
std::cout << "<= EXIT" << std::endl;
clean_up_and_exit(0);
return 0;
}
_____________________________________
Sent from http://octave.1599824.n4.nabble.com
[Prev in Thread] | Current Thread | [Next in Thread] |