Commit 6afa7dba authored by Jesse Heckman's avatar Jesse Heckman
Browse files

added predict sine to vPrime

parent 295044a1
......@@ -60,22 +60,18 @@ function [x,t] = VC_sinesignal(dur, SR, freq)
t = 0:1/SR:dur;
x = sin(w*t);
L = length(t);
x = x.* tukeywin(L,0.25)';
tsz = length(t);
x = x .* tukeywin(tsz,0.25)';
end
function [x,t] = VC_predictedsine(dur, SR, freq) %%% <--- TO DO: FIX THE TRANSFER FUNCTION!!
% function generates a perfect sine output
a = 1.39;
b = 1.4;
w = freq*2*pi;
t = 0:1/SR:dur;
x = (b*sin(w*t) + w*cos(w*t))/a;
xfun = pb_y2x();
L = length(t);
x = x.* tukeywin(L,0.25)';
tsz = length(t);
x = xfun(1,freq,t) .* tukeywin(tsz,0.25)';
end
function [x,t] = VC_turnsignal(dur, SR)
......@@ -85,6 +81,7 @@ function [x,t] = VC_turnsignal(dur, SR)
v = randn(1,1);
x = v*t;
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
......
......@@ -15,6 +15,10 @@ function [Dat,profile,dur] = pb_vSignalVC(handles)
signal(1) = block(bnumber).signal.ver;
signal(2) = block(bnumber).signal.hor;
signal = pb_vSafety(signal);
for iSig = 1:2
if strcmp(signal(iSig).type,'sine'); signal(iSig).type = 'predictsine'; end
end
%% CREATE BASIC SIGNAL
vSignal = pb_vCreateSignal(1, signal(1).duration, 10, signal(1).frequency, signal(1).type);
......
......@@ -61,7 +61,7 @@ function pb_vRunExp(handles)
for iTrl = 1:nTrials
% Runs all trials within one block
% setup trial
updateTrial(handles);
stim = handles.block(iBlck).trial(iTrl).stim;
......
......@@ -11,8 +11,8 @@ Random 0 % 0=no, 1=per set, 2=all trials
Motor n
Lab 5
% AX SIG AMP DUR
% edg bit Event Time Event Time
% AX SIG AMP DUR FREQ
%
% MOD X Y ID INT On On Off Off Event
% edg bit Event Time Event Time
......
function x = pb_y2x(y,H)
% PB_Y2X(y, H)
function x = pb_y2x(varargin)
% PB_Y2X(varargin)
%
% PB_Y2X() transforms the symbolic wanted output expression to a symbolic
% required input expression, using Laplace transformation and the system's
% transfer function.
% PB_Y2X(varargin) returns a matlabFunction to achieve a wanted vestibular
% output. Note that if no input arguments are provided. Transfer function
% and wanted output are chosen by default parameters.
%
% See also PB_ITF
% See also PB_VCREATESIGNALS, MATLABFUNCTION
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
syms s t x X Y
syms x y h X H Y s t w a f
if nargin == 1
% if no tf was provided select default parameters (tf2 for VC model dat with ampl. 15).
syms H s N D
N(s) = 2.002*s + 0.01492;
D(s) = s^2 + 2.009*s + 0.0145;
H(s) = N/D;
end
Y(s) = laplace(y);
X(s) = Y(s)/H(s);
def = loaddefaults;
H = pb_keyval('H',varargin,def.H);
y = pb_keyval('y',varargin,def.y);
Y = laplace(y);
X = Y/H;
x = ilaplace(X);
x = matlabFunction(x);
end
x = ilaplace(X(s));
function def = loaddefaults
% Default functions for keyval
syms x y h X H Y s t w a f
w = f*2*pi;
def.H = (2*s + 0.015)/(s^2 + 2*s + 0.015); % default transfer function VC
def.y = a*sin(w*t); % default output VC (sine)
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment