help-octave
[Top][All Lists]
Advanced

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

Using plot() in C++ file


From: Mitchal Dichter
Subject: Using plot() in C++ file
Date: Wed, 14 Mar 2012 01:01:11 -0700

I have successfully used mkoctfile to compile a C++ file with octave code in it.

#include <iostream>
#include <octave/oct.h>

int main (void)
{
    Matrix x = Matrix(1,10);
    std::cout << x;
    return 0;
}

output:
 0 0 0 0 0 0 0 0 0 0

I think I have been able to call octave functions from the C++ file as well.

#include <octave/oct.h>

int main (void)
{
    Matrix x = Matrix(10,10);
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            x(i,j) = i+j;
        }
    }
    EIG e = EIG(x);
    return 0;
}

no output

My problem is I can't figure out how to call plot() from within the
C++ file and have it create a graph. Right now it won't even compile.
It says plot is not a defined function.

#include <octave/oct.h>

int main (void)
{
    int n = 10;
    Matrix x = Matrix(n,1);
    Matrix y = x;
    plot(x,y);
    return 0;
}

mkoctfile --link-stand-alone -o Octave Octave.cpp

Octave.cpp: In function ‘int main()’:
Octave.cpp:8:13: error: ‘plot’ was not declared in this scope

Is it even possible to use plot in a C++ function? Also, if anyone can
recommend a good tutorial for types and functions available from
octave/oct.h that would be especially helpful.

Thank you for your time.
Mitchal


reply via email to

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