f



Exporting data from C++ to Matlab --> using pointers in c++ instead of...

If i have:
    //option 1 - it doesn't work
    float *nou;
    nou = (float *) calloc(50, sizeof(float));
    //option 2 - it works
    float nou[15];

How can I send "nou" to Matlab if it's a pointer (option 1)??? -
option 2 works with the code:

I'm using this code:
mxArray *TxNou = NULL;
TxNou = mxCreateNumericMatrix(1, 15, mxSINGLE_CLASS, mxREAL);
memcpy((void *)mxGetPr(TxNou), (void *)nou, sizeof(nou));
matlab.PutVariable("TxNou", TxNou);
matlab.EvalString("plot(TxNou);");

I don't know what changes I have to do in the code - i've tried a lot
of things... i don't find the error!

Thanks for your advice,

Oscar
0
11/9/2005 1:36:38 PM
comp.soft-sys.matlab 211266 articles. 24 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
935 Views

Similar Articles

[PageSpeed] 51

Oscar Esteve wrote:
> If i have:
>     //option 1 - it doesn't work
>     float *nou;
>     nou = (float *) calloc(50, sizeof(float));
>     //option 2 - it works
>     float nou[15];
> 
> How can I send "nou" to Matlab if it's a pointer (option 1)??? -
> option 2 works with the code:
> 
> I'm using this code:
> mxArray *TxNou = NULL;
> TxNou = mxCreateNumericMatrix(1, 15, mxSINGLE_CLASS, mxREAL);
> memcpy((void *)mxGetPr(TxNou), (void *)nou, sizeof(nou));
Why not use mxGetData and avoid the cast?
in option 1:
   sizeof(nou) = sizeof(float *) = 4 on 32 bit, 8 on 64bit.
In option 2:
   sizeof(nou) = 15*sizeof(float) = 15*4 = 60
> matlab.PutVariable("TxNou", TxNou);
> matlab.EvalString("plot(TxNou);");
> 
> I don't know what changes I have to do in the code - i've tried a lot
> of things... i don't find the error!
> 
> Thanks for your advice,
> 
> Oscar
0
cchgroupmail (818)
11/9/2005 1:51:44 PM
Reply:

Web resources about - Exporting data from C++ to Matlab --> using pointers in c++ instead of... - comp.soft-sys.matlab

Gas Exporting Countries Forum - Wikipedia, the free encyclopedia
The Gas Exporting Countries Forum ( GECF ) is an intergovernmental organization of 11 of the world's leading natural gas producers made up of ...

Facebook Updates Comments Box Plugin With Comment Exporting and Larger News Feed Stories
Facebook today released several updates to the newest version of its Comments Box social plugin for third party websites that will increase the ...

The Price of Oil book review: Paints a gloomy picture for prices, companies and exporting countries
In Roberto Aguilera and Marian Radetzki's new book, The Price of Oil, the two economists are optimistic about the expansion of global oil production ...

Lower dollar a boon for Canberra's wine exporting king
It may mean more expensive holidays for some, but one ACT registered company has enjoyed a profitable time thanks to the sharp fall in the Australian ...

Irish plant shut for exporting horsemeat
Sky News is Australia's leader in 24-hour news.

New online freight marketplace Cargohound aims to be the Uber of exporting
Cargo Hound wants to revolutionise the way goods are shipped from Australia.

Exporting the desperate; out of sight ... and mind
The boats have stopped, the point's been made, so why continue to treat those already ''here'' with such unconscionable cruelty?

Meat market: Andrew Forrest sees fortune in exporting beef to China
China is so desperate for good beef that Australian billionaire Andrew Forrest will be taking sample parcels of steak in his luggage on his next ...

Exporting carbon and hypocrisy: our big growth industry
Never mind our modest cuts to local emissions, new research shows Australia is heading into a carbon export boom.

Montreal men accused of illegally exporting railway equipment to Iran
Two Montreal men are charged with illegally exporting American-made railway equipment to Iran, violating Canada's Export and Import Permit Act ...

Resources last updated: 3/25/2016 2:04:08 AM