How do you vary the load parameter of the "RLC Series Load" Block during a simulation from the GUI?
7 次查看(过去 30 天)
显示 更早的评论
So I've been trying to control the active power of a load from the GUI while the simulation is running with no avail. I've been trying the following code, which is written in a Matlab Function block in Simulink:
function EVL = VarLoad(t)
%Allow the use of functions for standalone code
coder.extrinsic('set_param');
coder.extrinsic('num2str'); %Maybe it takes strings?
Test_Power = [4000 ; 5000; 6000; 3000]; %Matrix with power values
persistent t_ref Cell;
if isempty(t_ref) %Initialize if time = 0
t_ref = 0;
Cell = 1;
end
if t >= t_ref+0.1 %If desired time has elapsed change cell
t_ref = t_ref+0.1; %Set the new reference time
Cell = Cell + 1; %Move onto the next cell
else %Don't change
t_ref = t_ref;
Cell = Cell;
end
EVL = Test_Power(Cell,1); %Set the power equal to the corresponding time
set_param('PV_MPPT_inv_bat_Final/Household Loads/Series RLC Load', 'ActivePower', 'EVL')
It seems that EVL doesn't update in the workspace as the code is running. Also, I was wondering if I am even allow to manipulate SimPowerSystems during a simulation? I understand you can manipulate gain blocks and such, but what about this block's power parameter? If not does anyone have a clue as to how I could model a variable load? Please help and thanks for your time!
回答(1 个)
Vishal Neelagiri
2017-6-22
There is no way to directly modify Simscape parameter values during the simulation. There are two workarounds for this:
1) Create a custom Simscape component that would take an additional input through Simulink. This would enable you to specify the ActivePower parameter through a Simulink block and pass this value as an input to a custom Simscape component that you build. The following documentation link gives some detail about the workflow involved in creating a custom Simscape component: http://www.mathworks.com/help/physmod/simscape/creating-custom-components.html
2) Simscape Run-Time Parameter. You would also be able to utilize Simscape Run-Time Parameters to modify parameter values without recompiling. However, you would still not be able to change the value of a run-time configurable parameter during simulation. You can only change the value of a run-time configurable parameter when a simulation is stopped. Further detail about Simscape Run-Time Parameters can be found at the following page: http://www.mathworks.com/help/physmod/simscape/ug/about-simscape-run-time-parameters.html
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Environment Customization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!