MATLAB Answers

How to generate a user-defined pulse input from excel at simulink stateflow

8 views (last 30 days)
Feng Wu
Feng Wu on 18 Feb 2019
Answered: Feng Wu on 21 Feb 2019
Hi there,
I'm using stateflow in the simulink to do some modeling work. Basically, I wanna use some pulse signal to trigger the event in certain conditions. Followings are some simple model I developed.
I wonder how can I generate a pulse based on the input of excel file, for example the figure below:
Thanks in advance,

Answers (2)

Mundrathi Venugopal
Mundrathi Venugopal on 19 Feb 2019
You can take a signal builder block and import the excel file into the signal builder from its options.
Your pulse input to be specified must be represented in excel as follows.
e.g. time column followed by number of data columns(i.e, number of signals) in one sheet (i.e, one group in signal builder)
time value
0 0
2 0
2 1
8 1
8 0
10 0
i.e, you specified a pulse from time 2 ~8 and elsewhere it is 0.
We can generate this pulse signal from Chart using temporal instructions also if We wanted to.

Feng Wu
Feng Wu on 21 Feb 2019
Hi Mundrathi,
Thanks for answering. I tried a lot these two days. It worked in some part. But it still has some problems.
The stateflow I developed is quite simple.
I use the excel as input for the signal builder, and I followed your instruction.
However, When I run the simulation, it didn't work very well as a pulse signal. see figure below. I can't figure out why it suddenly decreases to 0 when the input still equal to 1(purple line is the pulse input,yelow line is the output based on the stateflow before).
However, if I setting the simple time to 0.02 seconds(the existance time of pulse is 0.02s) in the simulation options in the singal builder, then it works well.
Sorry for the long replay. It gives me some headache. Could you give some suggestions?
many thanks,

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!