0
votes

I am trying to call Simulink block every 30seconds but I am unable to do it. I am using a demo from matlab sscfluids_house_heating_system and I need to work with temperatures every 30 seconds in my MATLAB function block. But only each 30seconds. Image1

I tried creating simple code for running that block only every 30 seconds (at this moment it calls only after 30seconds) but it works only in matlab not in MATLAB function block

 if(exist('isRunning','var') == 0)
        timeA = datetime('now');
        timeA = datevec(timeA);
        isRunning = 1
    else
        timeB = datetime('now');
        timeB = datevec(timeB);
        disp(etime(timeA,timeB))
        if(etime(timeB,timeA) >= 30)
            sayIt = "30secPassed"
        end
    end

So my question is what can I do to call MATLAB function block every 30 seconds?

1

1 Answers

0
votes

Solution was to set sample time to 30 sec in block parameters(subsystem). enter image description here