Skip to main content
. 2021 Sep 29;21(19):6516. doi: 10.3390/s21196516
Listing A1. Matlab commands for fault detection.
  • 1

    function [I_out, I_Fault, Vout, V_Fault]= ...

  • 2

    fcn (IoutM, IoutK1, IoutK2, VoutM, VoutK1, VoutK2)

  • 3

     

  • 4

    I_Fault=0;

  • 5

    V_Fault=0;

  • 6

    ConI1=abs(IoutM-IoutK1)

  • 7

    ConI2=abs(IoutM-IoutK2)

  • 8

    ConV1=abs(VoutM-VoutK1)

  • 9

    ConV2=abs(VoutM-VoutK2)

  • 10

    CondI2=abs(IoutK2(k)-IoutK2(k-1))

  • 11

     

  • 12

    if ConI2>res1 && ConV2<res2 && ConI1<res3

  • 13

       if CondI2 < res4

  • 14

        I_Fault=1;

  • 15

       else

  • 16

         I_Fault=0;

  • 17

       end

  • 18

    else

  • 19

       I_Fault=0;

  • 20

    end

  • 21

     

  • 22

    if ConV1>res5 && ConI1<res6 && ConV2>res7

  • 23

       V_Fault=1;

  • 24

    else

  • 25

       V_Fault=0;

  • 26

    end

  • 27

     

  • 28

    if I_Fault==1 && V_Fault==0

  • 29

       Iout=IoutK2;

  • 30

       Vout=VoutM;

  • 31

    elseif V_Fault==1

  • 32

       Iout=IoutM;

  • 33

       Vout=VoutK1;

  • 34

    else

  • 35

       Iout=IoutM;

  • 36

       Vout=VoutM;

  • 37

    end