matlab - How to turn off code generation in Simulink? (function is not supported for standalone code generation) -


i creating simulation port language myself. don't need use code generation capabilities of simulink. how turn it's attempts allow code generation off?

for example, have following code inside matlab function block:

function outimage = resizecroppad(inimage, width, height) %#codegen      %coder.extrinsic('imresize');      % resizing defined height     scale = height/size(inimage,1);     inimage = imresize(inimage, scale);      % cropping defined width     if width<size(inimage,2)         padarray(inimage, [0 size(inimage,2)-width], 0, 'both');     elseif width>size(inimage,2)         b = floor((width-size(inimage,2))/2);         inimage = inimage(:,b:b+width-1,:);     end      outimage = inimage; 

and gives error

the function 'imresize' not supported standalone code generation. see documentation coder.extrinsic learn how can use function in simulation.

if uncomment coder.extrinsic('imresize') line new error

expected either logical, char, int, fi, single, or double. found mxarray. mxarrays returned calls matlab interpreter , not supported inside expressions. may used on right-hand side of assignments , arguments extrinsic functions.

addressing line 11, if.

why? possible disable code generation, example @ model level?

you need uncomment coder.extrinsic('imresize'); line , declare/initialise inimage variable before calling imresize function. see converting mxarrays known types more info.

edit following discussion in comments:

the following should work:

function outimage = resizecroppad(inimage, width, height) %#codegen      coder.extrinsic('imresize');      % resizing defined height     scale = height/size(inimage,1);     outimage = inimage;     outimage = imresize(inimage, scale);      % cropping defined width     if width<size(outimage,2)         padarray(outimage, [0 size(outimage,2)-width], 0, 'both');     elseif width>size(outimage,2)         b = floor((width-size(outimage,2))/2);         outimage = outimage(:,b:b+width-1,:);     end 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -