필터 지우기
필터 지우기

Inizialize variable s function builder C

조회 수: 1 (최근 30일)
alessandro mutasci
alessandro mutasci 2022년 10월 13일
답변: Manas 2023년 9월 8일
Good evening, I have read the manual for S function, but I still couldnt understand how to inizialize an array in the s function boiler block. I hope someone could help me, telling me how to inizialize a variabile, lets say an array of 10 elements, that is an intemediate variabile in the script, I fill the array with the input.. in C I use the following code: static double a{}. Thank you.

답변 (1개)

Manas
Manas 2023년 9월 8일
Hi Alessandro Mutasci,
I understand that you are facing difficulties conceptualizing defining variables and managing them in S functions.
To initialize variables which in your case is an array, you need to first allocate the appropriate amount of space. You can use the “ssSetUserDataSize” and “ssSetOptions” functions for this purpose.
ssSetUserDataSize(YourStructElement, sizeof(double) * ARRAY_SIZE);
Later, you can follow basic C constructs and paradigms to input a variable, loop over the array and assign data.
I would highly recommend looking at S function examples from the MATLAB documentation here https://www.mathworks.com/help/simulink/sfg/s-function-examples.html to gain more clarity.

카테고리

Help CenterFile Exchange에서 Deploy to C++ Applications Using mwArray API (C++03)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by