Exporting C++code to Visual Studio using the Simulink model yields incorrect results

I have a Simulink model that includes the Three Phase Breaker module, Three Phase Source module, and Switch module. After exporting C++code using Simulink coder and running it in visual studio 2022, the results are inconsistent with those running in Simulink.The Matlab version used is 2023a.

2 件のコメント

Uday
Uday 2024 年 6 月 4 日
Hi
Can you share the details of the errors you got?
defeat
defeat 2024 年 6 月 4 日
Thank you very much for your interest in this issue, so far we have got the reason why this error occurred.Since we use a three-phase source in the simulink model and set variables at the phase voltage of the three-phase source, when the code is generated, the variable representing the amplitude of the three sources in the code is assigned a fixed value. Therefore, the generated code is based on a simulnik model, so when we change the values of these variables in visual studio, we do not get the correct result.

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

回答 (1 件)

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU 2024 年 6 月 4 日

0 投票

Hi Defeat,
Can you try the following solutions?
  • Use a parameterizable Three Phase Source block to define voltages as parameters adjustable in Visual Studio.
  • Utilize an external signal source (function/signal) for phase voltages, allowing control in Visual Studio.
  • For advanced needs, consider a custom Simulink Coder block for dynamic voltage control

1 件のコメント

defeat
defeat 2024 年 6 月 7 日
Thank you very much for your suggestion, we will try it.

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

カテゴリ

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

製品

リリース

R2023a

質問済み:

2024 年 5 月 29 日

コメント済み:

2024 年 6 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by