two inputs operation in an s function or embedded Matlab function

1 visualización (últimos 30 días)
Owen
Owen el 16 de Oct. de 2012
Hi,
an S function or Embedded Matlab function has two inputs with the same sample frequency and one output. Input1 is a data stream of integers, Input2 indicates how many elements from this sample point shall be output. The output has the same number of elements. The dimensions of inputs and output are all 1x1.
Example:
Input1: … 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 …
Input2: … 0 0 2 0 0 0 3 0 0 0 0 4 0 0 0 0 0 0 0 0 …
Output: …NaN NaN 3 4 NaN NaN 7 8 9 NaN NaN 12 13 14 15 NaN NaN NaN NaN NaN ...
How to implement this with the easiest way? What about logical and?
Thanks Senmeis
  1 comentario
Mariano Lizarraga
Mariano Lizarraga el 16 de Oct. de 2012
Senmeis, I think you need to clarify your question and your example a little bit more. If you say the inputs and outputs are all scalars, then if we take your example at sample time 3, then input1=3, input2=2 and I understand that output=3. So far so good, but at the next sample time, t=4, input1 = 4, input2=0 and I understand that you meant that the output be 4 because of input1 at t=3. But what happens if input2 instead of being 0 at t=4 is now not zero, say 4? Do you accumulate, do you discard the previous count? Also, having an output being NaN is not a good practice, you should probably reconsider your "No output" constant.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by