필터 지우기
필터 지우기

Problem with C-Caller

조회 수: 10 (최근 30일)
paolo dini
paolo dini 2023년 8월 1일
댓글: paolo dini 2023년 8월 11일
Hello everyone,
i am just traing to use the C-caller, in very simple way actually but i have encauntered issue already for this simple exercse.
I have the following situation. In the same folder a created:
1) "my_functions.c" with the following content:
#include "my_functions.h"
void my_function_1 (int A, float B, double* C){
*C = A*B;}
int my_function_2 (int A, int B){
return A + B;}
2) "my_functions.h" with the following content:
void my_function_1 (int, float, double*);
int my_function_2 (int, int);
(Actually i have tried also with "external" before the functions prototypes, but it does not works).
3) "esempio_c_caller.slx" where i use the C-caller block.
Actually the code i have the follwing message in the diagnostic viewer when compile my code "Parsing Custom Code in model:'esempio_C_caller' successful." and in fact the c-caller adapt it form on the function i select from the mask interface.
The problem is the folowing, calling for example, my_function_2() connecting sin wave blocks (connected with data type conversion block...) and try to plot the sum, the resulting signal is always equal to zero.
Have you some suggestion?
If i forgot something to secting in the configuration, in order to use C code during simulation?
or other things...
Thanks for attention to All in advance!
PS: i use 2018b version in this case, but i have installe also more recent version (2020b + 2022b) so if workaround is change the version, could be not an issue for me.

답변 (1개)

David Balbuena
David Balbuena 2023년 8월 10일
Your model runs and produces results on my end. It's possible that the scope is not scaled properly for you to see the output. Try clicking the auto-scale button to see if that changes anything:
  댓글 수: 1
paolo dini
paolo dini 2023년 8월 11일
Dear David,
first of all, thanks to spent some of your time to check for my issue.
Actually the problem was the extension of the "file.C", as you can notice, what i have uploaded is a "file.C.txt", wich is not recognised as C file from my file system.
I solved forced the extension from terminal (cmd).
I know was a stupid issue after all.
Thanks again!!
Best,
Pierpaolo.

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

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by