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.

4

2 回答 2

1

Simulink/Stateflow 更喜欢数字数据。您应该使用 ASCII 值的整数表示(使用 uint8 或 uint16 数据类型),这将使比较几乎变得微不足道。

于 2015-01-23T19:40:39.527 回答
0

Matlab并没有明确区分只有一个char和一个char的字符串,据我所知,在stateflow中不可能使用字符串类型。将输入转换为整数,然后仅使用状态图中的整数比较。您可以使用此函数在 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
于 2016-10-19T13:30:48.737 回答