Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Block Parameters

Status
Not open for further replies.

Claire88

Industrial
Jan 5, 2011
3
Dear all,
I'm just getting started with Simulink, worked myself yesterday through 100pages of tutorial and 12hour of videos - well at least it felt this way. And of course everything is much more complicated than I expected. I hope I'm not bothering you now with some stupid beginners questions:

I need to change the parameters of a Block during the simulation. E.g. take a Sine-source and change the frequency.
I tried a workaround with an "embedded Matlab Block", but there I could not find an access to the system time.

Do you have any suggestions?

 
Replies continue below

Recommended for you

Off the top of my head, open the sine generator up, type an equation in t in the line for the frequency.

Or, create an m block with 2 inputs , stick t in one, from the clock, and your desired frequency into the other, and enter an appropriate equation into the block, with one output.



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Hi Greg!

Thanks for your answer!
Unfortunately equations in t don't work in the parameter field.
The clock part is doing the job here, thanks!!!

I still have other blocks where I would like to edit the parameters, e.g. a transfer function which I would like to tune during the simulation.

I have seen that one can use Matlab variables as parameters.
Is there a way to change a simple matlab variable from simulink? E.g. let's define variable "time" which should be set by a clock-source.
 
Yes sorry, method 1 was wrong.

The way I did method 2 was to create an embedded function block sine_out, with 2 input args freq and time, drove freq from the ramp generator and time from the clock.

Writing variables back and forth into and out of matlab is possible, at a guess using in and out ports. I think you have to enable something in the system config as well.





Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Hi Greg!
Thanks, yes I tried the Input/Output blocks "From Workspace" and "To Workspace". "To Workspace" creates an array or more complex structures where time and value are stored. I couldn't get them to overwrite a simple integer variable which each sampling.
 
Hi,

I think you can use "tag" blocks (From/Goto) from 'Signal Routing' lib to define a tunable parameter.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor