Find Time when two conditions are met in two colomns

I have data set
Colomn 1= Time in micro seconds
Colomn 2 = Negative voltage
Colomn 3 = Out put current pulse
(1) How to get Time when Current is 50% after max negative voltage is applied BEFORE peak Current (MAX)
(2) How to get Time when Current is 50% after max negaitve voltage is applied AFTER Peak Current (MAX)
clear
data =load('Data1.txt');
Time=data(:,1);
Voltage=data(:,2);
Current=data(:,3);

 Risposta accettata

dpb
dpb il 8 Giu 2020
Modificato: dpb il 8 Giu 2020
Really don't need the applied signal at all to answer the Q?...
data=load('Data1.txt');
[Imx,iImx]=max(data(:,3)); % find, locate peak
ixRise=find(data(:,3)>=Imx/2,1,'first'); % and rise and
ixFall=find(data(:,3)>=Imx/2,1,'last'); % fall locations...
The above has the granularity of the sampling rate; you could also then use interp1 intersection to get and find the actual intersection if that much precision is needed.
fmt="Peak time (msec): %.1f, Max I: %.3f\n50%% TRise (msec): %.1f TFall(msec): %.1f\n";
>> fprintf(fmt,data(iImx,1)*1E6,Imx, data(ixRise,1)*1E6, data(ixFall,1)*1E6)
Peak time (msec): 39.6, Max I: 59.474
50% TRise (msec): 18.6 TFall(msec): 41.2
>> (maxk(data(:,3),10)) % Inspect peak current area --
ans =
59.4738
57.0392
57.0392
57.0392
57.0392
56.6914
56.3436
56.3436
56.3436
56.3436
>>
One might consider using an average or smoothing instead of the one-point maximum above...for at least this dataset, there are five values at the plateau with just the one spike that is the actual peak max that may well be tied in with the change in input? That's a little more involved, but above gives the idea.
plot(data(:,1),[data(:,2)/100 data(:,3)]) % scale applied signal to be able to see detail easily
ylim([-20 70]) % and set appropriate y range
yline(Imx/2,'r:','HalfMax');
plot(data(ixRise,1),Imx/2,'r*')
plot(data(ixFall,1),Imx/2,'r*')
Of course, should plot and examine first before doing anything...above yields

4 Commenti

Thanks, I am just begnner. Please show me how you do this
Not getting this, where do you defined ixRise?
fmt="Peak time (msec): %.1f, Max I: %.3f\n50%% TRise (msec): %.1f TFall(msec): %.1f\n";
>> fprintf(fmt,data(iImx,1)*1E6,Imx, data(ixRise,1)*1E6, data(ixFall,1)*1E6)
Peak time (msec): 39.6, Max I: 59.474
50% TRise (msec): 18.6 TFall(msec): 41.2
dpb
dpb il 8 Giu 2020
Modificato: dpb il 9 Giu 2020
Oh, sorry...trimmed too much in cleaning up for neatness...
See Ammended Answer for "the rest of the story!"
Fantastic. This is working. One more query related to above data.
How can we get Time when voltage is reached 980V.
Actual point is 980 but there is some overshoot as well but I want time when Voltage is 980V.
Same idea -- but be aware there may not be an exact match to a floating point number so using "==" in find is somewhat risky. ismembertol solves a lot of those kinds of issues pretty simply.
As above, you return the index and look up time from it...

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2020a

Richiesto:

il 8 Giu 2020

Commentato:

dpb
il 10 Giu 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by