[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave findpeaks called from cellfun gives an error
From: |
Juan Pablo Carbajal |
Subject: |
Re: Octave findpeaks called from cellfun gives an error |
Date: |
Wed, 29 Jan 2014 20:04:04 +0100 |
On Wed, Jan 29, 2014 at 7:58 PM, Andrew Knyazev <address@hidden> wrote:
> Juan, thank you for your prompt reply! I apologize for reporting this by
> email. I have tried to report it using the bug tracker, but I do not have my
> login credentials here with me.
>
> The loop below gives the same error. The issue I guess is that cellfun
> requires the data to be cell, which is apparently not supported by
> findpeaks. Of course, one can just run the loop with numeric values in
> findpeaks, avoiding the problem altogether. This is why I report this as an
> improvement, not as a bug.
>
> I am guessing that findpeaks is not the only function having this issue in
> Octave...
>
> Thanks, Andrew
>
>
> On 1/29/2014 1:21 PM, Juan Pablo Carbajal wrote:
>>
>> Andrew, please use the bug tracker to report the bug (also keep the
>> community posted). It will get lost in my inbox.
>>
>> Could you please check the following loop code, I suspect that the
>> error has nothing to do with cellfun
>> C = num2cell(abs(dCd),1);
>> H = num2cell(mPH,1);
>> for i = 1:numel(C)
>> [~, locs] =
>> findpeaks(C{i},'minpeakheight',H{i},'minpeakdistance',mPSI);
>> endfor
>>
>> Thank you
>>
>> On Wed, Jan 29, 2014 at 6:58 PM, Andrew Knyazev <address@hidden> wrote:
>>>
>>> Dear Juan Pablo Carbajal,
>>>
>>> Thank you for contributing your findpeaks Octave code to the community!
>>>
>>> May I have a small request for improvement? It appears that the function
>>> findpeaks cannot be used from cellfun, as it gives an error, e.g.,:
>>>
>>> [~, locs] =
>>> cellfun(@(x,y)findpeaks(x,'minpeakheight',y,'minpeakdistance',mPSI), ...
>>> num2cell(abs(dCd),1),num2cell(mPH,1),'UniformOutput',0);
>>>
>>> error: findpeaks: subscript indices must be either positive integers or
>>> logicals
>>> error: called from:
>>> error:
>>>
>>> C:\Octave\Octave3.6.4_gcc4.6.2\share\octave\packages\signal-1.2.1\findpeaks.m
>>> at line 126, column 5
>>>
>>> The above works in MATLAB 2010b
>>>
>>> It would be nice if this issue could be fixed in future releases.
>>>
>>> Best regards, Andrew
>>>
>
>
Andrew, if the loop gives the error it has nothing to do with cellfun.
The problem is that for some of your data findpeaks is failing and
that can be a bug.
Could you find what is the offending data by looking at "i" in the
loop after findpeaks fails. If it possible please upload that data so
we can try it.