How to send continuous data from simulink block
Show older comments
Hello,
I have to develop a model in Simulink which can send data continuously, the sent data should be stored in a block and if it reaches some predetermined value. It should trigger the next block.
I increase the value of a constant block by this code..!
for a=1:0.1:10
set_param('MyModelName/Constant','Value',num2str(a)) %send a to the model
pause(1) %pause for 1 second
end
but it is not sending the data continuously, everytime i have to press Run button.
let me know ur idea
Thanks in advance
9 Comments
Azzi Abdelmalek
on 17 Aug 2012
what do you want exactly to do? and from where u are sending data
Rahul kumar
on 20 Aug 2012
Edited: Rahul kumar
on 20 Aug 2012
Rahul kumar
on 20 Aug 2012
Albert Yam
on 20 Aug 2012
What is a data storage block? [My Simulink Browser couldn't find it. Note. Simulink 6.6.1]
What do you want to have happen?
a=1:0.1:10 -> if a>thresh -> [boolean used as a trigger for enable]
Is this right?
Rahul kumar
on 20 Aug 2012
Edited: Rahul kumar
on 20 Aug 2012
Albert Yam
on 20 Aug 2012
What do you mean by store some boolean data? Do you mean output [To Workspace] after? Is the boolean data to be used elsewhere?
I still do not see why you need to store it. Would a conditional block there suffice? Isn't the signal coming out of that conditional block be what you are looking for?
Rahul kumar
on 20 Aug 2012
Edited: Rahul kumar
on 20 Aug 2012
Rahul kumar
on 20 Aug 2012
Edited: Rahul kumar
on 20 Aug 2012
Rahul kumar
on 20 Aug 2012
Answers (3)
Ryan G
on 17 Aug 2012
2 votes
I don't think this code does what you think it does. There is no real-time operations between MATLAB and Simulink, so when you pause for 1 second it could take 1.5 seconds to process the next point in the sim or it could take 100 seconds in the sim depending on how fast it moves.
Try pre-packaging the data with a Time and Data vector and utilizing a To Workspace block or an Inport. For continuity you want to enable interpolation.
1 Comment
Kaustubha Govind
on 17 Aug 2012
I think Ryan meant to say "From Workspace" instead of "To Workspace" block. :)
Albert Yam
on 17 Aug 2012
0 votes
Why do you need the 'pause'? If you want an input to 'change over time', use a look-up table, or signal generator.
hm..deja vu
1 Comment
Albert Yam
on 21 Aug 2012
You still have yet to explain why you need to store the value, and you just reiterated your wording, almost verbatim, so no, not more clear.
clock -> Look-up(n-D) -> Compare to Constant ---> Scope(2)
--------------------------> Scope(1)
Where
Look-up(n-D)
table dimensions = 1
First input (row) = 0:length(a)-1
Table data = a %where in workspace: >> a = 0:0.1:10;
Compare to Constant
Operator = >
Constant value = 5
Rajan
on 20 Aug 2012
0 votes
I don't think you can change a value used in constant block ,as the name of the block suggests ,it is a constant value through out the execution.
Don't sent the data from a constant block , instead make a simple addition which increments by 0.2 every time with in the model(not from the code) and send the output of sum block to your data store block . Or compare the output of sum block with comparator block (==6).
I hope this serves your cause.
1 Comment
Rahul kumar
on 20 Aug 2012
Categories
Find more on Signal Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!