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

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?

댓글을 달려면 로그인하십시오.

추가 답변 (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 Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by