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.

 採用された回答

Kaustubha Govind
Kaustubha Govind 2012 年 10 月 29 日

0 投票

Have you already specified the input structure type in the project?

4 件のコメント

Conrad
Conrad 2012 年 10 月 30 日
Yeah the input is defiend as double.
Kaustubha Govind
Kaustubha Govind 2012 年 10 月 31 日
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.
Conrad
Conrad 2012 年 10 月 31 日
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?
Kaustubha Govind
Kaustubha Govind 2012 年 11 月 2 日
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?

サインインしてコメントする。

その他の回答 (1 件)

Conrad
Conrad 2012 年 10 月 30 日

0 投票

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?

カテゴリ

ヘルプ センター および File ExchangeMATLAB Coder についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by