Time delay in matlab fuction block used in simulink model.

Hi, I developed a power system in simulink. Here, i also use matlab function block and some coding in it. Now i want that when simulink power system starts to simulate, then matlab function block do not operate for first 2 seconds of simulation. In other words i want 2 second time delay of matlab function block. How can i perform that?
Thanks

 Accepted Answer

Jim Riggs
Jim Riggs on 30 Jul 2018
Edited: Jim Riggs on 30 Jul 2018
Place your Matlab function block into a triggered subsystem block (or an enabled subsystem block), then trigger/enable the block based on time.

11 Comments

Thanks for answering.
But actually i want to do is that, function block give 1 output to circuit breaker till 2 seconds of simulation and after 2 seconds then it should follow this code.
function y = fcn(A)
if A >= 1.8200e+06
y=0
else y=1
end
Kindly suggest changes in coding for that
This is simply selecting between two constant values based on a logical condition. This network performs this task. The logical compares A with 1.8200e+6. When true, it enables the upper subsystem block, which simply outputs the constant 0. When the logic is false, the lower block is enabled, which simply outputs a constant value 1. The merge block us used to combine the outputs of two or more enabled blocks, where only one is enabled at a time.
After looking at your post again, I think that maybe this is what you want; Do something for the first two seconds, then output 0 or 1 based on the value of A. In this case, the top-most enabled block is run for the first two seconds, then the lower network is enabled and outputs a value based on the value of A.
Yes this is exactly i want. The y should be equal to 1 till first 2 seconds of simulations and after 2 seconds the value of y should base on value of A. Can you suggest changes in code for that?
function y = fcn(A)
if A >= 1.8200e+06
y=0
else y=1
end
This is what the last network does. The top enabled subsystem should output a value of 1. This network outputs 1 for the first two seconds, and then either 0 or 1 based on the value of A.
It really help me. Thanks for your help
function y = fcn(A,time)
if(time <= 2.0)
y=1;
else
if (A >= 1.8200e+06)
y=0;
else
y=1;
end
end

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!