Can anyone tell me what blocksets should I use to do the
same job as MATLAB function "find" does?
For example, if I have an input signal x = [1 0 -10 -2 2 3]
and I want to find elements great than zero, so the output
signal should be y =[ 1 2 3], how do I do this with
SIMULINK blocks?
Thanks for your help.
The Variable Selector block in Signal Processing blockset supports
logical indexing. But in Simulink the dimensions cannot change. So if
you use x > 0 as indices the output will be y = [1 2 3 0 0 0].
Navan
Oops, that's too bad. Maybe I should write a s-function istead.
Anyway, thanks for your concern.
Ryan
Regards,
Mollin
x=input('input a arry, x=');
m=0;
n=length(x);
for i=1:n
if x(i)>0
m=m+1;
y(m)=x(i);
end
end
y
Thanks for your help first and your code does work in
MATLAB environment BUT failed in SIMULINK model.
Ryan
Thanks for ur kind reminder that the size of the ouput should be
initialized or defined in advance, which prohibits me from creating
dynanmical sized ouput.
Oh gee, what do I suppose to do?
Ryan