[Scilab-users] Regarding simple numerical operations result display.

Berns Buenaobra berns.buenaobra at gmail.com
Mon Mar 18 01:25:42 CET 2013


Hi Stefan:

Maybe I should like to get some insight how to do this.

What I have is two columns (or 2 column vectors) and they need to go in
pairs say magnitude y and a position in x say P(x,y). Now what I wanted is
to be able to detect peaks from a set threshold value - I would like to
keep 10 values above it in memory and discard the rest. I I repeat the same
action until I only get the highest of all these column vector magnitudes
at the last threshold value. There is a uniform delta for each of the
threshold value I use going from bottom up.

Problem: I can detect the peaks alright but how does one ensure that it
sticks to its position pair? Since indexing the magnitude seemed to a
sequential location in memory and not its position?

Thanks for any help.

Regards,
Berns B.
USC Physics




On Mon, Mar 18, 2013 at 5:24 AM, Stefan Du Rietz <sdr at durietz.se> wrote:

> But this is the ultimate solution without a loop:
>
> -->bool2s(y>a) .* b + bool2s(~y>a) .* y
>  ans  =
>   - 11.  - 6.  - 1.    4.    100.
>
> /Stefan
>
>
> On 2013-03-17 22:05, Stefan Du Rietz wrote:
> --------------------
>
>> Maybe one of the last two of these four loops was what you wanted:
>>
>> -->bool2s(y>a)
>>   ans  =
>>      0.    0.    0.    0.    1.
>>
>> -->for k=bool2s(y>a), if k, disp(b), else, disp(y), end, end
>>    - 11.  - 6.  - 1.    4.    9.
>>    - 11.  - 6.  - 1.    4.    9.
>>    - 11.  - 6.  - 1.    4.    9.
>>    - 11.  - 6.  - 1.    4.    9.
>>      100.
>>
>> -->for k=y, if k>a, disp(b), else, disp(y), end, end
>>    - 11.  - 6.  - 1.    4.    9.
>>    - 11.  - 6.  - 1.    4.    9.
>>    - 11.  - 6.  - 1.    4.    9.
>>    - 11.  - 6.  - 1.    4.    9.
>>      100.
>>
>> Here, k takes the value of each element in y:
>>
>> -->for k=y, if k>a, disp(b), else, disp(k), end, end
>>    - 11.
>>    - 6.
>>    - 1.
>>      4.
>>      100.
>>
>> Or maybe this is easier to follow:
>>
>> -->for k=1:length(y), if y(k)>a, disp(b), else, disp(y(k)), end, end
>>    - 11.
>>    - 6.
>>    - 1.
>>      4.
>>      100.
>>
>> /Stefan
>>
>> On 2013-03-17 20:46, Stefan Du Rietz wrote:
>> --------------------
>>
>>> Sorry,
>>> I should have written (?):
>>>
>>> A multi-element logical array is true (T) only if all elements are T.
>>> -->and(y>a)
>>>   ans  =
>>>    F
>>>
>>> /Stefan
>>>
>>> On 2013-03-17 20:35, Stefan Du Rietz wrote:
>>> --------------------
>>>
>>>> -->y=(5*x)-1
>>>>   y  =
>>>>    - 11.  - 6.  - 1.    4.    9.
>>>>
>>>> -->y>a
>>>>   ans  =
>>>>    F F F F T
>>>>
>>>> This is F (the first element)
>>>>
>>>> /Stefan
>>>>
>>>>
>>>> On 2013-03-17 20:23, Modestas Bunokas wrote:
>>>> --------------------
>>>>
>>>>> If someone will find 2 min of free time, I would be very grateful.
>>>>> I'm
>>>>> somehow getting weird result doing simple operation like:
>>>>>
>>>>> a=7;  b=100;  x=[-2:1:2];  y=(5*x)-1;
>>>>> if  y>a  then  disp(b);
>>>>>      else  disp(y);
>>>>> end
>>>>>
>>>>> --> - 11.  - 6.  - 1.    4.    9.
>>>>>
>>>>> Last result (9) is wrong, it should be 100 (b). I fully understand
>>>>> that it's because of lack of my knowledge in programming but in few
>>>>> days I could not solve or even could not find any help. Because of
>>>>> that writing here.
>>>>>
>>>>>
>>>>> ______________________________**_________________
>>>>> users mailing list
>>>>> users at lists.scilab.org
>>>>> http://lists.scilab.org/**mailman/listinfo/users<http://lists.scilab.org/mailman/listinfo/users>
>>>>>
>>>>>
>>>> ______________________________**_________________
>>>> users mailing list
>>>> users at lists.scilab.org
>>>> http://lists.scilab.org/**mailman/listinfo/users<http://lists.scilab.org/mailman/listinfo/users>
>>>>
>>>>
>>> ______________________________**_________________
>>> users mailing list
>>> users at lists.scilab.org
>>> http://lists.scilab.org/**mailman/listinfo/users<http://lists.scilab.org/mailman/listinfo/users>
>>>
>>>
>> ______________________________**_________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/**mailman/listinfo/users<http://lists.scilab.org/mailman/listinfo/users>
>>
>>
> ______________________________**_________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/**mailman/listinfo/users<http://lists.scilab.org/mailman/listinfo/users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20130318/0fd74df0/attachment.htm>


More information about the users mailing list