Prev: Persistent webcam ID
Next: triggered single pulse
From: Gerrit Hofbauer on 11 Mar 2010 11:32 "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> schrieb im Newsbeitrag news:hnb4li$1oq$1(a)fred.mathworks.com... > > The vector behavior needs to be present in the function itself. Otherwise > you will have to use a loop in the calling routine. e.g., you could change > your function code to something like this: > > xlt2 = x < 2; > xlt500 = (~xlt2) & (x < 500); > f = ones(size(x)) * 0.44; > f(xlt2) = 24./x(xlt2); > f(xlt500) = 18.5./x(xlt500).^0.6; > > All of that logical indexing does incur a memory and speed penalty which > may be an issue for very large x. This could be avoided in the above case > by using a C mex routine if necessary. > > James Tursa I didn't even know there was something like logical indexing. That should help me for further work to come. Thanks a lot to everyone! Gerrit |