Effacer les filtres
Effacer les filtres

Convert c++ structs to mwArray, to use in c++ shared library

1 vue (au cours des 30 derniers jours)
hnde
hnde le 9 Fév 2011
Hello,
I have a function in matlab which uses structs. For example, if I have the struct:
A.Header.title='myTitle';
A.Header.xlabel='Time';
A.Header.ylabe='Values';
A.Values=rand(1, 100);
A.Times=1:100;
my function takes the struct A as input, and plots it and does some other data processing and opens a GUI.
I have compiled this function with the Matlab Compiler and I want to call it from C++. In C++ I generate the struct A with C++ data, and in C++ the struct A has the exact same fields. But how can I pass the struct in C++ as input to my compiled Matlab function. I could not find a way to convert the struct in C++ to the mwArray type and make it suitable as an input for my compiled matlab code. Is there any way I can do this?
Thank you very much.

Réponses (1)

Kaustubha Govind
Kaustubha Govind le 9 Fév 2011
  3 commentaires
Kaustubha Govind
Kaustubha Govind le 10 Fév 2011
Think of it more as a struct array with four elements, and each struct has 3 fields ("name", "phone", "hometown"). So it's not possible that "name" and "phone" have a different number of elements. How would you achieve what you need in C++? The best you can do is to set "name" to an empty string for the extra array elements that you need for "phone".
Kaustubha Govind
Kaustubha Govind le 10 Fév 2011
Actually, I think your question is better answered in http://www.mathworks.com/matlabcentral/answers/1152-dimension-of-fields-in-mwarray-structs

Connectez-vous pour commenter.

Catégories

En savoir plus sur Deploy to C++ Applications Using mwArray API (C++03) dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by