How can I covert a Matlab struct 1x1 to C++ without an error?

Hi,
I tried to generate C++ from Matlab with the Matlab coder. But I always got an error.
The error is:
>> coder -build test_struct.prj ??? This structure does not have a field 'fs'.
Error in ==> gen_strucht Line: 3 Column: 15 Code generation failed: Open error report.
Here is the Matlab-Code:
function [test_struct] = gen_strucht(test)
test_struct.x=test.fs;
test_struct.y=test.ts;
test_struct.a=test.modfac;
test_struct.q= test_struct.x * test_struct.a;
end
So what can I do?
Thanks for help.

 Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 29 de Oct. de 2012
Have you already specified the input structure type in the project?

4 comentarios

Yeah the input is defiend as double.
Don't you need to define it as a structure, and not as double? See How to Add a Field to a Structure to see how you can define the various fields in the structure.
Thanks for the tipp. So i defined the input value as a struct and I defined the different fields. But now I got the same error for the output field 'q'. Is there a way to define the output value/fields?
Conrad: MATLAB Coder should automatically determine the output type, so you shouldn't have to specify it. Could you paste the exact error message that you get?

Iniciar sesión para comentar.

Más respuestas (1)

Conrad
Conrad el 30 de Oct. de 2012
There I think is my second problem. In this struct I have double and chars, and I can only define one type. Is it possible to define a second type?

Categorías

Más información sobre MATLAB Coder en Centro de ayuda y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by