Something wrong when i Convert raw to LFP in line15

It seems something goes wrong in the first guessing of the optimal parameters x0 in the function fitLFPpowerSpectrum.

Can you debug your code around lines [32-41] in fitLFPpowerSpectrum, to understand what is going on?

    %Guestimate the optimal parameters
    smoothpsdy = ksr(log(freqs),logpsdy);
    [gm,maxidx] =  max(diff(smoothpsdy.f));
    c0 = smoothpsdy.x(maxidx+1);
    d0 = max(smoothpsdy.f);
    b0 = 1;
    a0 = (min(smoothpsdy.f)-d0)/(log(Fh)-c0);
    
    %Initialize guesses for parameters
    x0 = [a0;b0;c0;d0];

The fitLFPpowerSpectrum is part of the derivelfp plugin, so it is located in your Brainstorm [User directory]/ plugins/derivelfp/DeriveLFP/toolbox

The location of the [User directory] depends of your OS, as indicated here:
https://neuroimage.usc.edu/brainstorm/Tutorials/CreateProtocol#Brainstorm_folders

Failed to fix it.
The debug code you give is as same as original.
The magical thing is i run the program successful yesterday, but it not work this morning.

By debugging I meant to use some breakpoints to understand the issue:
https://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html

The lines I put were to indicate where the debugging needs to be done.