|
From: | Raghavendra K |
Subject: | Re: Regarding Standalone Program |
Date: | Wed, 30 Jul 2008 16:58:30 +0530 |
> I am trying to use 2 functions of Octave in my C++ program, they areAs David suggested, there's no need to use "zeros" - the Matrix
> zeros and expm
> When I was using MatlabI was able to contact the matlab engine from the C
> program using this
> ep = engOpen("/usr/local/Matlab/bin/matlab
> and then execute any function of matlab like this
> engEvalString(ep, "T_a = expm(T_a);");
>
> Is there any equivalent way of doing this in Octave?
> If yes can you please provide some pointers as to how to go about it.
> Thanks a lot for your time.
>
constructor will do the trick.
Similarly, the Matrix::expm () method will give you the matrix exponential.
You *can* evaluate Octave commands from within C++ using eval_string
(declared in parse.h). However, as David noted, to use the parser
engine you first need to initialize it, and you'll need to transfer
the data to and from the symbol table (if you use normal C++
variables). Unless you need to call an m-file function, there is
normally a more straightforward way that avoids using the parser.
> _______________________________________________
> On Wed, Jul 30, 2008 at 1:32 PM, David Bateman <address@hidden>
> wrote:
>>
>> Raghavendra K wrote:
>>>
>>> Hi,
>>> I am trying to call octave functions from C, but getting an error.
>>> This is the code that I am using
>>>
>>> #include <iostream>
>>> #include <octave/oct.h>
>>> int
>>> main (void)
>>> {
>>> std::cout << "Hello Octave world!\n";
>>> int n = 2;
>>> Matrix a_matrix = Matrix (n, n);
>>> a_matrix = zeros(n, n);
>>> std::cout << a_matrix;
>>> return 0;
>>> }
>>>
>>
>> Try
>>
>> #include <iostream>
>> #include <octave/oct.h>
>> int
>> main (void)
>> {
>> std::cout << "Hello Octave world!\n";
>> int n = 2;
>> Matrix a_matrix = Matrix (n, n, 0.);
>> std::cout << a_matrix;
>> return 0;
>> }
>>
>>
>> instead. You can't call zeros like that but must use the feval function,
>> and if you need feval you have to initialize the parser. There are threads
>> in the mailing list about this..
>>
>> Regards
>> David
>>
>> --
>> David Bateman address@hidden
>> Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc
>> Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob) 91193
>> Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
>> The information contained in this communication has been classified as:
>> [x] General Business Information [ ] Motorola Internal Use Only [ ]
>> Motorola Confidential Proprietary
>>
>
>
>
> --
> Regards,
> Raghavendra K
>
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>
>
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
[Prev in Thread] | Current Thread | [Next in Thread] |