How to extract and plot only minimal and maximal peaks of an array , -graph analysis- With Matlab or excel

后端 未结 3 1200
礼貌的吻别
礼貌的吻别 2020-12-11 18:16

I\'m doing video analysis.
The end result array I get is something like:

signal =

    Columns 1 through 7

       73960       73960       73960       73         


        
3条回答
  •  没有蜡笔的小新
    2020-12-11 18:48

    If you want the maximum and minimum values just use:

    [sig_min, idx_min] = min(signal);
    [sig_max, idx_max] = max(signal);
    

    But I couldnt understand exactly what you want… since my account is new, I cant comment on your question to try to understand it better.

    — edit 1:

    Ok, now I understand what you want. I don't know why you have this array with repetitive numbers, but supposing you don't want them, or, at least, that is better to remove them to find local maxima and minima, you should do:

    sinal_norep = signal(find(diff(sinal)));
    

    where signal_norep will be your new array containing only values that differs from the last one:

    On the left is your signal, on the right the new one

    Now we can search for the index where occurs local maxima and minima on this array, by doing:

    minimas_idx = find(signal_norep(2:end-1)signal_norep(1:end-2) & signal_norep(2:end-1)>signal_norep(3:end))+1;
    

    And their values:

    signal_maximas = signal_norep(maximas_idx);
    signal_minimas = signal_norep(minimas_idx);
    

    Thats it x)

提交回复
热议问题