@@ -4,7 +4,7 @@ function remoteMicrogridPlotFreAngle(logsout,caseNum,voltageLimit,frequencyLimit
44%
55% This plot shows the differences (Diesel and microgrid side) in voltage magnitude, frequency, and phase angle.
66
7- % Copyright 2022 - 2023 The MathWorks, Inc.
7+ % Copyright 2022 - 2024 The MathWorks, Inc.
88% Create new figure
99h4_remote_microgrid = figure(' Name' , ' h4_remote_microgrid' );
1010figure(h4_remote_microgrid )
@@ -26,56 +26,59 @@ function remoteMicrogridPlotFreAngle(logsout,caseNum,voltageLimit,frequencyLimit
2626logsout_islandvoltage = logsout .get(' IslandVoltage' );
2727
2828simlog_handles(1 ) = subplot(4 , 1 , 1 );
29-
29+ % Neglect the initial data to avoid transients
30+ tPlot = 2 ;
31+ tIndex = find(logsout_islandcommand .Values .Time > tPlot ,1 );
32+ tIndexPLL = find(logsout_gridfre .Values .Time > tPlot ,1 );
3033% selecting the plot
3134switch caseNum
3235 case 3
3336 % Plot results
34- plot(logsout_islandcommand .Values .Time , logsout_islandcommand .Values .Data , ' LineWidth' , 1 )
37+ plot(logsout_islandcommand .Values .Time( tIndex : end ) , logsout_islandcommand .Values .Data( tIndex : end ) , ' LineWidth' , 1 )
3538grid on
3639hold on
37- plot(logsout_islanding .Values .Time , logsout_islanding .Values .Data , ' LineWidth' , 1 )
40+ plot(logsout_islanding .Values .Time( tIndex : end ) , logsout_islanding .Values .Data( tIndex : end ) , ' LineWidth' , 1 )
3841grid on
3942hold on
40- plot(logsout_brkstatus .Values .Time , logsout_brkstatus .Values .Data , ' LineWidth' , 1 )
43+ plot(logsout_brkstatus .Values .Time( tIndex : end ) , logsout_brkstatus .Values .Data( tIndex : end ) , ' LineWidth' , 1 )
4144grid on
4245axis([2 8 - 0.1 2.5 ])
4346title(' Planned Island Command and BRK Status' )
4447legend({' Island Command' , ' Islanding' , ' BRK Status' },' NumColumns' ,3 );
4548
4649 case 4
4750
48- plot(logsout_resynchcommand .Values .Time , logsout_resynchcommand .Values .Data , ' LineWidth' , 1 )
51+ plot(logsout_resynchcommand .Values .Time( tIndex : end ) , logsout_resynchcommand .Values .Data( tIndex : end ) , ' LineWidth' , 1 )
4952grid on
5053hold on
51- plot(logsout_resynchronization .Values .Time , logsout_resynchronization .Values .Data , ' LineWidth' , 1 )
54+ plot(logsout_resynchronization .Values .Time( tIndex : end ) , logsout_resynchronization .Values .Data( tIndex : end ) , ' LineWidth' , 1 )
5255grid on
5356hold on
54- plot(logsout_brkstatus .Values .Time , logsout_brkstatus .Values .Data , ' LineWidth' , 1 )
57+ plot(logsout_brkstatus .Values .Time( tIndex : end ) , logsout_brkstatus .Values .Data( tIndex : end ) , ' LineWidth' , 1 )
5558grid on
5659axis([2 8 - 0.1 2.5 ])
5760title(' Resynch Command and BRK Status' )
5861legend({' Resynch Command' , ' Resynchronization' , ' BRK Status' },' NumColumns' ,3 );
5962
6063 case 5
6164
62- plot(logsout_fault .Values .Time , logsout_fault .Values .Data , ' LineWidth' , 1 )
65+ plot(logsout_fault .Values .Time( tIndex : end ) , logsout_fault .Values .Data( tIndex : end ) , ' LineWidth' , 1 )
6366grid on
6467hold on
65- plot(logsout_brkstatus .Values .Time , logsout_brkstatus .Values .Data , ' LineWidth' , 1 )
68+ plot(logsout_brkstatus .Values .Time( tIndex : end ) , logsout_brkstatus .Values .Data( tIndex : end ) , ' LineWidth' , 1 )
6669grid on
6770axis([2 8 - 0.1 2.5 ])
6871title(' Fault and BRK Status' )
6972legend({' Fault' , ' BRK Status' },' NumColumns' ,2 );
7073end
7174
72- flag= sum(logsout_gridfre .Values .Data > 60+ frequencyLimit * 60 )+sum(logsout_gridfre .Values .Data < 60- frequencyLimit * 60 )+...
73- sum(logsout_islandfre .Values .Data > 60+ frequencyLimit * 60 )+sum(logsout_islandfre .Values .Data < 60- frequencyLimit * 60 );
75+ flag= sum(logsout_gridfre .Values .Data( tIndexPLL : end ) >60+ frequencyLimit * 60 )+sum(logsout_gridfre .Values .Data( tIndexPLL : end ) <60- frequencyLimit * 60 )+...
76+ sum(logsout_islandfre .Values .Data( tIndex : end ) >60+ frequencyLimit * 60 )+sum(logsout_islandfre .Values .Data( tIndex : end ) <60- frequencyLimit * 60 );
7477simlog_handles(1 ) = subplot(4 , 1 , 2 );
75- plot(logsout_gridfre .Values .Time , logsout_gridfre .Values .Data , ' LineWidth' , 1 )
78+ plot(logsout_gridfre .Values .Time( tIndexPLL : end ) , logsout_gridfre .Values .Data( tIndexPLL : end ) , ' LineWidth' , 1 )
7679grid on
7780hold on
78- plot(logsout_islandfre .Values .Time , logsout_islandfre .Values .Data , ' LineWidth' , 1 )
81+ plot(logsout_islandfre .Values .Time( tIndexPLL : end ) , logsout_islandfre .Values .Data( tIndexPLL : end ) , ' LineWidth' , 1 )
7982
8083
8184grid on
@@ -95,28 +98,26 @@ function remoteMicrogridPlotFreAngle(logsout,caseNum,voltageLimit,frequencyLimit
9598axis([2 8 58 67 ])
9699ylabel(' Frequency (Hz)' )
97100legend({' Diesel Frequency' , ' Island Frequency' ,' Frequency Limits' },' NumColumns' ,3 );
98- % legend({'Inverter', 'Diesel'});
99-
100101
101102
102103simlog_handles(1 ) = subplot(4 , 1 , 3 );
103- plot(logsout_gridangle .Values .Time , logsout_gridangle .Values .Data , ' LineWidth' , 1 )
104+ plot(logsout_gridangle .Values .Time( tIndexPLL : end ) , logsout_gridangle .Values .Data( tIndexPLL : end ) , ' LineWidth' , 1 )
104105grid on
105106hold on
106- plot(logsout_islandangle .Values .Time , logsout_islandangle .Values .Data , ' LineWidth' , 1 )
107+ plot(logsout_islandangle .Values .Time( tIndexPLL : end ) , logsout_islandangle .Values .Data( tIndexPLL : end ) , ' LineWidth' , 1 )
107108grid on
108109title(' Diesel and Island Voltage Angle' )
109110ylabel(' Angle (deg)' )
110111axis([2 8 - 190 190 ])
111112legend({' Diesel voltage angle' , ' Island voltage angle' },' NumColumns' ,2 );
112113
113- flag1= sum(logsout_gridvoltage .Values .Data > 1+ voltageLimit )+sum(logsout_gridvoltage .Values .Data < 1- voltageLimit )+...
114- sum(logsout_islandvoltage .Values .Data > 1+ voltageLimit )+sum(logsout_islandvoltage .Values .Data < 1- voltageLimit );
114+ flag1= sum(logsout_gridvoltage .Values .Data( tIndexPLL : end ) >1+ voltageLimit )+sum(logsout_gridvoltage .Values .Data( tIndexPLL : end ) <1- voltageLimit )+...
115+ sum(logsout_islandvoltage .Values .Data( tIndexPLL : end ) >1+ voltageLimit )+sum(logsout_islandvoltage .Values .Data( tIndexPLL : end ) <1- voltageLimit );
115116simlog_handles(1 ) = subplot(4 , 1 , 4 ); % #ok<*NASGU>
116- plot(logsout_gridvoltage .Values .Time , logsout_gridvoltage .Values .Data , ' LineWidth' , 1 )
117+ plot(logsout_gridvoltage .Values .Time( tIndexPLL : end ) , logsout_gridvoltage .Values .Data( tIndexPLL : end ) , ' LineWidth' , 1 )
117118
118119hold on
119- plot(logsout_islandvoltage .Values .Time , logsout_islandvoltage .Values .Data , ' LineWidth' , 1 ,' Color' ,' black' )
120+ plot(logsout_islandvoltage .Values .Time( tIndexPLL : end ) , logsout_islandvoltage .Values .Data( tIndexPLL : end ) , ' LineWidth' , 1 ,' Color' ,' black' )
120121if flag1 > 0
121122plot([2 , 8 ],[1 + voltageLimit ,1 + voltageLimit ],' LineWidth' ,1 ,' Color' ,' r' ,' LineStyle' ,' -' )
122123plot([2 , 8 ],[1 - voltageLimit ,1 - voltageLimit ],' LineWidth' ,1 ,' Color' ,' r' ,' LineStyle' ,' -' )
0 commit comments