how to get multiple output in legacy code tool

3 views (last 30 days)
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.

Answers (1)

abouessire ismail
abouessire ismail on 27 Mar 2019
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 ;) .

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!