Programatically changing block parameter during simulation.
Show older comments
I am automatically changing the amplitude value of my sin wave block in my model. But the problem is that my program runs the simulation multiple times and do not change the values of amplitude during one simulation. this is the code:
amplitude_vec=(0.5:0.2:2.3);
for i=1:10
amplitude=amplitude_vec(i);
sim('Amplifier.mdl');
end;
How do i write a program that will change the values of amplitude of my sin wave block in one simulation run ?
Thanks for your help,
Janez
2 Comments
Accepted Answer
More Answers (1)
Mariano Lizarraga
on 25 Aug 2012
Edited: Mariano Lizarraga
on 25 Aug 2012
I might be misunderstanding your problem statement but if you only want to change the amplitude base on the time of the simualtion then you could do an embedded matlab function as follows:
function y = timeDependentSine(t, amplitude, freq, phase, bias)
y = amplitude*sin(freq*t + phase) + bias;
and now all the parameters for the sine function can be time varying if you so desire. You can implement all in Simulink as shown here: http://skit.ch/nwn1
Categories
Find more on Programmatic Model Editing 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!