[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: find subvector with findstr / strfind
From: |
inor0627 |
Subject: |
Re: find subvector with findstr / strfind |
Date: |
Fri, 8 Apr 2016 03:04:13 -0700 (PDT) |
NJank wrote
> On Wed, Feb 17, 2016 at 8:13 AM, inor0627 <
> ingo.ortlepp@
> >
> wrote:
>
>> I used to locate a sequence of numbers in a longer vector via findstr(),
>> e.g.
>> findstr( [3 4 5 3 4] , [3 4] )
>> ans = 1 4.
>> Today I came across the information that findstr() is scheduled for
>> deprecation and one should use strfind() instead.
>>
>> However, trying
>> strfind( [3 4 5 3 4] , [3 4] )
>> results in:
>> error: strfind: PATTERN must be a string or cell array of strings.
>
> [...]
> this does not appear anywhere in the help documentation though, which
> calls
> for the input to be a string. Methinks Matlab is automatically doing a
> type
> conversion, and either strings are turned into numeric arrays and searched
> for the pattern, or the numeric array is converted to a char array and
> then
> handled as a string.
> [...]
> All that said, Octave normally goes with following the declared function
> properties. chasing down every undocumented matlab quirk can become an
> impossible task as mathworks could change things next version with no
> indication or regression announcement.
>
> nick j
Hello,
sorry for reviving this old thread, but meanwhile I came to a solution which
might interest others, facing the same problem:
pkg load signal;
x=[3 4 5 3 4];
y=[3 4];
[R lag]=xcorr(x,y);
R=R./sum(y.^2);
[~,idx]=find( abs(R - 1) <= eps);
lag(idx)+1
ans = 1 4
find( abs(R - 1) <= eps) is necessary as find (R==1) does not work properly
for negative floating point values.
Ingo
--
View this message in context:
http://octave.1599824.n4.nabble.com/find-subvector-with-findstr-strfind-tp4674858p4676169.html
Sent from the Octave - General mailing list archive at Nabble.com.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: find subvector with findstr / strfind,
inor0627 <=