%Close all old figures
%close all

if (exist('daten')==0)
    sim('hydroplant_MS3_091110');
end

% Populate an array for easier access to the measured values
% (the main advantage is that you don't have to remember the indices
%  and that one can change them later on without changing the rest of 
%  the code)
ind.h_W=1;
ind.V_flw_T=2;
ind.V_flw_F=3;
ind.p_F=4;
ind.omega=5;
ind.U=6;
ind.I=7;
ind.P=8;
ind.x=9;


% Plot the simulated values in a 3x3 subplot

% Plot the orifice position
subplot(3,3,1)
plot(daten.time, daten.signals.values(:,ind.x),'r');
xlabel('Zeit [s]');
ylabel('Position der Ventilnadel [-]');
title('Ventil Position');

% Plot the water height in the surge chamber
subplot(3,3,2)
plot(daten.time, daten.signals.values(:,ind.h_W),'r');
xlabel('Zeit [s]');
ylabel('Wasserstand [m]');
title({'Vorgegebenes Blackboxmodell';'by: SYSMOD';'';'Wasserstand im Wasserschloss'});

% Plot the head at the orifice
subplot(3,3,3)
plot(daten.time, daten.signals.values(:,ind.p_F),'r');
xlabel('Zeit [s]');
ylabel('Druck [Pa]');
title('Druck vor Ventil');

% Plot the Water flow though the tunnel
subplot(3,3,4)
plot(daten.time, daten.signals.values(:,ind.V_flw_T),'r');
xlabel('Zeit [s]');
ylabel('Volumenstrom Tunnel [m^3/s]');
title('Volumenstrom Tunnel');

% Plot flow through penstock
subplot(3,3,5)
plot(daten.time, daten.signals.values(:,ind.V_flw_F),'r');
xlabel('Zeit [s]');
ylabel('Volumenstrom Fallrohr [m^3/s]');
title('Volumenstrom Fallrohr');

% Plot turbine speed
subplot(3,3,6)
plot(daten.time, daten.signals.values(:,ind.omega),'r');
xlabel('Zeit [s]');
ylabel('\omega [rad/s]');
title('Drehgeschwindigkeit der Turbine');

% Plot U net
subplot(3,3,7)
plot(daten.time, daten.signals.values(:,ind.U),'r');
xlabel('Zeit [s]');
ylabel('Spannung [V]');
title('Spannung');

% Plot I net
subplot(3,3,8)
plot(daten.time, daten.signals.values(:,ind.I),'r');
xlabel('Zeit [s]');
ylabel('Strom [A]');
title('Strom');

% Plot total power delivered to net
subplot(3,3,9)
plot(daten.time, daten.signals.values(:,ind.P),'r');
xlabel('Zeit [s]');
ylabel('Leistung [W]');
title('Leistung');



