MATLAB: Trying to find an aproximate value in a data set

data

i have a data set that generates a pulse I(t), i am tring to find the delta t to go 10% max I(t) to 90% max I(t), i am havaing a hard time figureing out how to find those values of t from my exisitng data set. here is the code I am using to generate the data
%C = input(Prompt_1); % Enter the value of C in F%
C = 75E-9;
%L = input(Prompt_3); % Enter the value of L in H
L = 15E-9;
%R = input(Prompt_2); % Enter the value of R in Ohm
R = 600E-3;
%V = input(Prompt_4); % Enter the value of V in volts
V= 15E3;
%t = input(Prompt_5); % Define your time window
t = 0:1E-12:.5E-6;
% Figure out the dampened state of your circuit
if R^2 < (4.*L)/C
P = 'Circuit Underdamped'
w = sqrt((1/(L.*C))-(R./(2.*L))^2);
I = (V./(w.*L)).*exp(-(R./(2.*L)).*t).*sin(w.*t);
plot(t,I)
xlabel('Time (s)')
ylabel('Currnet (A)')
title('Plot of Current Vs Time for Underdamped')
elseif R^2 > (4.*L)/C
P = 'Circuit Overdamped'
w = sqrt(((R./(2.*L))^2)-(1./(L.*C)));
I = (V./(w.*L)).*exp(-(R./(2.*L)).*t).*sinh(w.*t);
plot(t,I)
xlabel('Time (s)')
ylabel('Current (A)')
title('Plot of Current Vs Time for Overdamped')
elseif R^2 == (4.*L)/C
P = 'Circuit Criticaly Damped'
I = (((V.*t)./L).*exp(-(R./(2.*L)).*t));
plot(t,I)
xlabel('Time (S)')
ylabel('Current (A)')
title('Plot of Current Vs Time for Criticaly Damped')
end
disp('I in (A), t in s, Idot in A/S')
Imax = max(I)
Iloc = find(I==Imax);
tmax = t(1,Iloc)
Idot_1 = Imax./tmax
I90 = Imax*.9;
I10 = Imax*.1;

Best Answer

disp('I in (A), t in s, Idot in A/S')
[Imax,Iloc] = max(I);
tmax = t(Iloc);
Idot_1 = Imax./tmax;
disp([Imax tmax Idot_1])
I90 = Imax*.9;
I10 = Imax*.1;
tSP=interp1(I(1:Imax),t(1:Imax),[I10 I90]); % find times, constrain to look from origin to max
xline(tSP(1),'k:');
xline(tSP(2),'k:');