From: C.C.Shiu on
I am now having problems when running my simulation with a Level-2
m-file s-function that i have created. I recieve the following block
error when i simulate:

Source 'untitled/Level-2 M-file S-Function' cannot have dynamic frame
data setting for its output port 1. All sources should explicitly set
all their output ports to be frame or non-frame.

Please help me to solve this problem. Thanks!

Here's my code (its pretty simple so i guess I'm missing somethimg):

function VideoIn22(block)
% Level-2 M file S-Function for times two demo.
% Copyright 1990-2004 The MathWorks, Inc.
% $Revision: 1.1.6.1 $

setup(block);

%endfunction

function setup(block)

%% Register number of input and output ports
block.NumInputPorts = 0;
block.NumOutputPorts = 1;

%% Setup functional port properties to dynamically
%% inherited.

block.SetPreCompOutPortInfoToDynamic;

block.OutputPort(1).Dimensions = 1;
%% Set block sample time to inherited
block.SampleTimes = [0 0];

%% Run accelerator on TLC
block.SetAccelRunOnTLC(true);

%% Register methods
block.RegBlockMethod('Outputs', @Output);

%endfunction

function Output(block)

vid = videoinput('matrox',1,'M_RS170');
frame = getsnapshot(vid);

row = 480; column=640; %image size row x column
img_no = 1;

A = frame;
thresh_img= im2bw(A,0.2);
inv_img=abs(thresh_img-1);
inv_img1=inv_img;

for i=450:480;
inv_img1(i,:)=0;
end

for t=1:column;
line(t)=1;
end

for t=1:row;
result(t)=line*inv_img1(t,:)';
end

% search the point
for i=3:1:(row-1)
if (result(i-1)==0) && (result(i)>=1) &&
(result(i+1)>=1) && (result(i+2)>=1 && (result(i+3)>=1));
pos_pix(img_no)=i;
end
end

inv_img1(pos_pix(img_no),:)=1;

actuate_mic=pos_pix*0.48 %pixels --> microns

block.OutputPort(1).Data = actuate_mic;

%endfunction