% RandJ_script.m -->  with RandJ.mdl
% EGR 390 HW 8
% J Cardell, April 2009
% Script for Simulink model of Romeo and Juliet's relationship

% Constants for A matrix
alpha = 1;  % the degree to which Romeo responds to Juliet's feelings
beta = -1;  % the degree to which Juliet responds to Romeo's feelings
delta = 0;  % the degree to which Romeo responds to his own feelings
gamma = 0;  % the degree to which Juliet responds to her own feelings

% Constants for B matrix
a = 0;      % binary 0/1 value for whether or not Romeo listens to friends
K1 = 5.0;   % degree to which Romeo listens to friends
b = 0;      % binary 0/1 value for whether or not Juliet listens to friends
K2 = 0.1;   % degree to which Juliet listens to friends

% Constants for duration of time during which R/J listen to their friends
% This is the 'step time' in the second input step for each person
Rstop = 5;
Jstop = 5;

% Define A to use for eigenanalysis, if needed
A = [gamma alpha; beta delta];  

% Run the simulink model
sim('RandJ');

% Define data vectors for plotting
t = Rin.time; 
uR = Rin.signals.values;   % Input to Romeo
uJ = Jin.signals.values;   % Input to Juliet
yR = Rfeel.signals.values; % Output - R(t) - Romeo's feelings
yJ = Jfeel.signals.values;

% plot the data
figure(1)
hold on
plot(t, uR, 'c-', t, uJ, 'bo', 'LineWidth', 2)
title('Input into Romeo and Juliet feelings')
grid

figure(2)
plot(t, yR, 'r-', t, yJ, 'b-', 'LineWidth', 2)
title('Romeo and Juliet''s Feelings')
grid

figure(3)
plot(yR, yJ, 'LineWidth', 2)
title('Romeo and Juliet in state space')
