Question: function [ phases , ref _ phase _ lags, phase _ lags, shil _ phase _ lags, binary _ states ] = SHIL ( model
function phases refphaselags, phaselags, shilphaselags, binarystates SHILmodel tspan, coupling, n
T linspacetspan tspan;
dt meandiffT;
Reference with no coupling to compute period
sol model tspan, n;
y sol.y;
t sol.x;
iyref interpt y: T;
plotT iyref;
Compute period from last half of data
period computeperiodiyref:end dt;
period
ts round period ;
phaselags ;
refphaselags ;
shilphaselags ;
binarystates ; To store binary states
Input and reference signal
phases linspace pi;
for phase phases
inputsignal profpulseT periodn phasen;
refsignal profpulseT period, phase;
Simulate system with input at SHIL frequency half natural period
sol modelperiod phase, coupling, tspan, n;
y sol.y;
t sol.x;
iy interpt y: T;
figure;
plotT iy;
Compute phase lag of result to reference signal, using last half of data
phaselag computephaseiyts:end refsignalts:end period, dt;
phaselagsend phaselag;
Compute phase lag of reference oscillator to ref signal, using last half of data
refphaselag computephaseiyrefts:end refsignalts:end period, dt;
refphaselagsend refphaselag;
Compute phase lag between SHIL and no SHIL
shilphaselag computephaseiyrefts:end iyts:end period, dt;
shilphaselagsend shilphaselag;
Determine binary state based on phase lag
threshold ; Adjust this threshold based on phase lag analysis
if phaselag threshold
binarystatesend;
else
binarystatesend;
end
figure;
hold on;
plotTts:end refsignalts:end maxiyr;
plotTts:end inputsignalts:end maxiyg;
plotTts:end iyts:endb;
plotTts:end iyrefts:endk;
titlegca sprintff phaselag;
end
ref
phaselags
phaselags
binarystates Display binary states
figure;
plotrefphaselags, phaselags, r 'MarkerSize', ;
hold on;
plotphasespi phaselags, g 'MarkerSize', ;
plotk;
plotk;
xlabelInitial phase degs;
ylabelFinal phase degs;
end
can you give step by step explaination of this code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
