% Jon Newman
% 2012 01 18
% Create figure for waveforms of pulsed LED

Ik = 10;
Pk = 30;
dsamp = 10;
sfac = 10;

% The 1 msec pulse
Vctl = load('ch1_vctl_led_1msec_pulse.isf');
Iled = load('ch2_iled_led_1msec_pulse.isf');
Pled = load('ch3_powled_led_1msec_pulse.isf');

% smooth and down-sample
t = Vctl(1:dsamp:end,1);
Vctl = smooth(Vctl(:,2),sfac);
Iled = smooth(Iled(:,2),sfac);
Pled = smooth(Pled(:,2),sfac);
Vctl = Vctl(1:dsamp:end);
Iled = Iled(1:dsamp:end);
Pled = Pled(1:dsamp:end);

close all
figure
subplot(211)
hold all
plot(t*1000,Vctl)
plot(t*1000,Ik*Iled)
plot(t*1000,Pk*Pled)
xlabel('time (msec)')
legend('V_{CTL}','I_{LED}','P_{LED}')


% The rise-time
Vctl = load('ch1_vctl_led_risetime.isf');
Iled = load('ch2_iled_led_risetime.isf');
Pled = load('ch3_powled_led_risetime.isf');

% smooth and down-sample
t = Vctl(1:dsamp:end,1);
Vctl = smooth(Vctl(:,2),sfac);
Iled = smooth(Iled(:,2),sfac);
Pled = smooth(Pled(:,2),sfac);
Vctl = Vctl(1:dsamp:end);
Iled = Iled(1:dsamp:end);
Pled = Pled(1:dsamp:end);

subplot(212)
hold all
plot(t*1000,Vctl)
plot(t*1000,Ik*Iled)
plot(t*1000,Pk*Pled)
xlabel('time (msec)')
legend('V_{CTL}','I_{LED}','P_{LED}')

export_fig 'HOSS_LED_Pulse' -transparent -pdf