1

I have to give ascii characters as input from simulink to stateflow and need to check whether the input matches with the existing ascii character. Can anyone help me to solve this? will be of a great help?

Example:

If I give ascii characters 'AF' as input from simulink to stateflow. It has to produce 1 as output if it matches with the existing ascii character in condition.

2 Answers2

1

Simulink/Stateflow prefer numeric data. You should use an integer representation of the ASCII value (using a uint8 or uint16 data type), which will make comparison almost trivial.

Phil Goddard
  • 10,571
  • 1
  • 16
  • 28
0

Matlab does not make a clear distinction between a string with just one char and a char, and as far as I know, it is not possible to use a string type in stateflow. Convert the input to integers then use only comparisons of integers inside the state chart. You can use this function to convert chars to integers in Matlab:

function [ integer ] = atoi( char )
%ATOI Ascii To Integer converts char to int
% 

integer = char - '0' + '0' ; %matlab seems a bit lunatic when it comes to chars

end
Florian Castellane
  • 1,197
  • 2
  • 14
  • 38