<div dir="ltr"><div><div><div><div>Hi Stefan:<br><br></div>Maybe I should like to get some insight how to do this.<br><br></div>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.<br>
<br></div>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?<br><br></div><div>
Thanks for any help.<br><br></div><div>Regards,<br></div><div>Berns B. <br></div><div>USC Physics<br></div><div><br></div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 18, 2013 at 5:24 AM, Stefan Du Rietz <span dir="ltr"><<a href="mailto:sdr@durietz.se" target="_blank">sdr@durietz.se</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">But this is the ultimate solution without a loop:<br>
<br>
-->bool2s(y>a) .* b + bool2s(~y>a) .* y<br>
ans =<br>
- 11. - 6. - 1. 4. 100.<span class="HOEnZb"><font color="#888888"><br>
<br>
/Stefan</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 2013-03-17 22:05, Stefan Du Rietz wrote:<br>
--------------------<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Maybe one of the last two of these four loops was what you wanted:<br>
<br>
-->bool2s(y>a)<br>
ans =<br>
0. 0. 0. 0. 1.<br>
<br>
-->for k=bool2s(y>a), if k, disp(b), else, disp(y), end, end<br>
- 11. - 6. - 1. 4. 9.<br>
- 11. - 6. - 1. 4. 9.<br>
- 11. - 6. - 1. 4. 9.<br>
- 11. - 6. - 1. 4. 9.<br>
100.<br>
<br>
-->for k=y, if k>a, disp(b), else, disp(y), end, end<br>
- 11. - 6. - 1. 4. 9.<br>
- 11. - 6. - 1. 4. 9.<br>
- 11. - 6. - 1. 4. 9.<br>
- 11. - 6. - 1. 4. 9.<br>
100.<br>
<br>
Here, k takes the value of each element in y:<br>
<br>
-->for k=y, if k>a, disp(b), else, disp(k), end, end<br>
- 11.<br>
- 6.<br>
- 1.<br>
4.<br>
100.<br>
<br>
Or maybe this is easier to follow:<br>
<br>
-->for k=1:length(y), if y(k)>a, disp(b), else, disp(y(k)), end, end<br>
- 11.<br>
- 6.<br>
- 1.<br>
4.<br>
100.<br>
<br>
/Stefan<br>
<br>
On 2013-03-17 20:46, Stefan Du Rietz wrote:<br>
--------------------<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sorry,<br>
I should have written (?):<br>
<br>
A multi-element logical array is true (T) only if all elements are T.<br>
-->and(y>a)<br>
ans =<br>
F<br>
<br>
/Stefan<br>
<br>
On 2013-03-17 20:35, Stefan Du Rietz wrote:<br>
--------------------<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-->y=(5*x)-1<br>
y =<br>
- 11. - 6. - 1. 4. 9.<br>
<br>
-->y>a<br>
ans =<br>
F F F F T<br>
<br>
This is F (the first element)<br>
<br>
/Stefan<br>
<br>
<br>
On 2013-03-17 20:23, Modestas Bunokas wrote:<br>
--------------------<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If someone will find 2 min of free time, I would be very grateful.<br>
I'm<br>
somehow getting weird result doing simple operation like:<br>
<br>
a=7; b=100; x=[-2:1:2]; y=(5*x)-1;<br>
if y>a then disp(b);<br>
else disp(y);<br>
end<br>
<br>
--> - 11. - 6. - 1. 4. 9.<br>
<br>
Last result (9) is wrong, it should be 100 (b). I fully understand<br>
that it's because of lack of my knowledge in programming but in few<br>
days I could not solve or even could not find any help. Because of<br>
that writing here.<br>
<br>
<br>
______________________________<u></u>_________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/<u></u>mailman/listinfo/users</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/<u></u>mailman/listinfo/users</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/<u></u>mailman/listinfo/users</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/<u></u>mailman/listinfo/users</a><br>
<br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/<u></u>mailman/listinfo/users</a><br>
</div></div></blockquote></div><br></div>