how to get multiple output in legacy code tool

4 次查看(过去 30 天)
Hai, Am try to achieve multiple output from LCT. I have written a .c and .h files as bellow
assign.c
#include “assign.h” Int assign(int In_1, int In_2, int In_3) { Int *Out_1, *Out_2, *Out_3; *Out_1 = In_1; *Out_2= In_2; *Out_3= In_3; }
assign.h
#ifdef ASSIGN_H #define ASSIGN_H Int assign(int In_1, int In_2, int In_3); #endif
And my legacy code is look like
def = legacy_code('intialize'); def.SFunctionName = 'sfun_addnum'; def.HeaderFile = { assign.h'}; def.SourceFile = { assign.c'}; def.OutputFcnSpec = ‘assign(int16 u1, int16 u2, int16 u3, int16 y1[1], int16 y2[1], int16 y3[1])’; legacy_code('sfcn_cmex_generater,def'); legacy_code('compile',def); legacy_code('slblock_generate',def);
Out of this codes I can able to generate a SFunction.c and Sfunction block also. But when I try to simulate the matlab get crashed. Please if any one knows the reason please share with me and also if you have an idea about how to get multiple output variables in LCT by using single c function return.

回答(1 个)

abouessire ismail
abouessire ismail 2019-3-27
Hi I hope that you get a solution for your problem .
if not yet the solution is :
assign.c
#include “assign.h”
Int assign(int In_1, int In_2, int In_3,Int *Out_1, int *Out_2,int *Out_3)
{
*Out_1 = In_1; *Out_2= In_2; *Out_3= In_3;
}
that's it .
Hope that tis will work for you ;) .

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by