Syntax Error with if statement expression block
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Batool Khader
el 3 de Mzo. de 2021
Respondida: Shiva Kalyan Diwakaruni
el 10 de Mzo. de 2021
I am trying to read the queried data from a serial COM port using Instrument Query block from Instrument Control Toolbox, where the input being queried is supposed to be one character such as 'C'. I would like to use the queried data in an if-statement block such that if it's equal to a certain character, then the model connected to the output is enabled and runs. However, since the queried data is in ASCII format, I added ASCII to String block to do the conversion. Despite all that, I get a syntax error as shown in the figure below. Could the issue be in my If expression?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/537761/image.png)
0 comentarios
Respuestas (1)
Shiva Kalyan Diwakaruni
el 10 de Mzo. de 2021
Hi,
The 'If' block cannot accept a signal of type string.It supports only
Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32
Instead you can use stringcompare block
or
compare to constant block
hope it helps,
thanks
0 comentarios
Ver también
Categorías
Más información sobre Sources en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!