How to inline this level 2 S function ?
2 views (last 30 days)
Show older comments
function Input_Stream_Level(block) % Level-2 M file S-Function Input_Stream_Level-2 % Copyright 1990-2004 The MathWorks, Inc. % $Revision: 1.1.6.1 $
setup(block);
%endfunction
function setup(block)
k = input('Specify the length of the String');
%% Register number of input and output ports block.NumInputPorts = 1; block.NumOutputPorts = 1;
%%Setup functional port properties to dynamically
%%inherited.
% block.SetPreCompInpPortInfoToDynamic;
% block.SetPreCompOutPortInfoToDynamic;
block.InputPort(1).Dimensions = 1;
block.OutputPort(1).Dimensions = [4*k];
% block.SetInputPortSamplingMode;
% block.InputPort(1).DirectFeedthrough = true;
%%Set block sample time to inherited
block.SampleTimes = [-1 0];
%%Run accelerator on TLC
block.SetAccelRunOnTLC(true);
%%Register methods
block.RegBlockMethod('Outputs', @Output);
%endfunction
function Output(block)
l = input('Specify the length of the String');
ut = input('Give the Hex value','S')
for p = 1:1:l
y(1,p:l) = ut(1,p)
end
for p = 1:1:l
if y(1,p) == 'A'
a = [1 0 1 0];
for h = 1:1:4
k(p,h) = a(1,h)
end
elseif y(1,p) == 'B'
b = [1 0 1 1]
for h = 1:1:4
k(p,h) = b(1,h)
end
elseif y(1,p) == 'C'
c = [1 1 0 0]
for h = 1:1:4
k(p,h) = c(1,h)
end
elseif y(1,p) == 'D'
d = [1 1 0 1]
for h = 1:1:4
k(p,h) = d(1,h)
end
elseif y(p) == 'E'
e = [1 1 1 0]
for h = 1:1:4
k(p,h) = e(1,h)
end
elseif y(p) == 'F'
f = [1 1 1 1]
for h = 1:1:4
k(p,h) = f(1,h)
end
elseif y(p) == '9'
nine = y(p)
nine = [1 0 0 1]
for h = 1:1:4
k(p,h) = nine(1,h)
end
elseif y(p) == '8'
eight = y(p)
eight = [1 0 0 0]
for h = 1:1:4
k(p,h) = eight(1,h)
end
elseif y(p) == '7'
seven = y(p)
seven = [0 1 1 1]
for h = 1:1:4
k(p,h) = seven(1,h)
end
elseif y(p) == '6'
six = y(p)
six = [0 1 1 0]
for h = 1:1:4
k(p,h) = six(1,h)
end
elseif y(p) == '5'
five = y(p)
five = [0 1 0 1]
for h = 1:1:4
k(p,h) = five(1,h)
end
elseif y(p) == '4'
four = y(p)
four = [0 1 0 0]
for h = 1:1:4
k(p,h) = four(1,h)
end
elseif y(p) == '3'
three = y(p)
three = [0 0 1 1]
for h = 1:1:4
k(p,h) = three(1,h)
end
elseif y(p) == '2'
two = y(p)
two = [0 0 1 0]
for h = 1:1:4
k(p,h) = two(1,h)
end
elseif y(p) == '1'
one = y(p)
one = [0 0 0 1]
for h = 1:1:4
k(p,h) = one(1,h)
end
elseif y(p) == '0'
zero = y(p)
zero = [0 0 0 0]
for h = 1:1:4
k(p,h) = zero(1,h)
end
end
end
z = reshape(k.', 1, numel(k))
% sys = z
block.OutputPort(1).Data = z
% block.OutputPort(1).Data = 2*block.InputPort(1).Data;
%endfunction
I am beginner to this application, Can anyone please tell me how to inline this Level 2 S function and then generating code out of it...
0 Comments
Answers (0)
See Also
Categories
Find more on Configure Block Features for MATLAB S-Functions 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!