Assume that a block receives integer numbers which can be seen as a x-axis. The "y-axis" returns strings which then are used to select output from a bunch of lookup tables.
The problem here is:
1. how to send strings as signals?
2. how to make a switch which is taking strings as input?
The reason for doing this? I am importing data from a proprietary system and do not want to map such constant strings into numbers since it would be difficult to make that robust. The code I am emulating is probably written in C using #define statements.
Regards,
Stefan Larsson
This solution answers your questions, but certainly isn't what you're
looking for. Simulink doesn't handle strings as a datatype for
signals. Still, maybe this will give you some additional insite to
the tools and the problem.
-Chris
0) create the 2 user defined functions below
1)add a constant source w/value of 1
2)using above as input, add a user defined matlab function w/function
name: sendstr
3)using above as input, add a user defined matlab function w/funciton
name: switchstr
4)using above as input, add a display block
function y=sendstr(u)
if u == 1
y = 'one ';
elseif u == 2
y = 'two ';
elseif u == 3
y = 'three';
else
y = 'zero';
end
y=abs(y);
function y=switchstr(u)
u=char(u)'
if strcmp(u,'one ')
y = 1;
elseif strcmp(u,'two ')
y = 2;
elseif strcmp(u,'three')
y = 3;
else
y = 0;
end
> The problem here is: 1. how to send strings as signals?
Use a uint8 vector signal.
> 2. how to make a switch which is taking strings as input?
Use the same length for all strings (i.e. uint8 vector signals),
pad shorter strings with zeros.
--
Ralph Schleicher <http://ralph-schleicher.de>
Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools