Does anyone know if there is a way to input a string into the
constant block in Simulink. If not, does anyone have a way of doing
this? Is the constant block hard coded, or is it an s function that I
can copy?
Many thanks
Greer Gray
Kelvin B. Hales
Kelvin Hales Associates Limited
Consulting Control Engineers
E-mail: kha...@khace.com
Web: www.khace.com
You can program the constant block to output a vector. Just program
the vector with the numerical equivalent of the ascii string you want
and set the output data type to int8 or uint8.
The null terminated string "abc" can be programmed into a constant block
by setting the value to [ 97, 98, 99, 0 ]. Unfortunately, it won't take
'a' instead of 97. Of course, the block you feed this to has to understand
that a vector of uint8 represents a null terminated string.
In xPC, the rs232 binary send block will take such a vector and send it
as a string for instance.
Gordon Weast
The Mathworks
xPC driver development
Actually it is possible to use the Constant Block to do something
sort of like this. It requires that you convert your string into a
vector of uint8 values using a simple Matlab expression. This is
done by placing the following type of expression into the Value field
of the Constant Block :
uint8('abcd')
If you do this in a model and connect it to a Display Block you'll
find that the output is a vector where each element in the vector
contains the ASCII code for the corresponding character in the string.
Hope this helps...
Dave
That's a fine example of using "any valid MATLAB expression in the
dialogue box that will evaluate to a numerical result at run time." :)