Borrar filtros
Borrar filtros

Using Matlab Function in Simulink

24 visualizaciones (últimos 30 días)
Frank
Frank el 19 de Dic. de 2011
Comentada: David el 18 de Mzo. de 2016
Hello, I am using in Simulink the "Matlab Function" block. The function in there is "diff(u)" This is just an example, the original function is much more complex. When I execute my simulation I get this error: Error in 'untitled/MATLAB Fcn'. Evaluation of expression resulted in an invalid output. Only finite double vector or matrix outputs are supported
What is the problem here?
  1 comentario
David
David el 18 de Mzo. de 2016
it is really unfortunate that no one from MATLAB has taken answering question on this forum seriously.

Iniciar sesión para comentar.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 19 de Dic. de 2011
Take the default parameter for the "MATLAB Fcn" block for example, the MATLAB function is "sin" so it get sin(x) as output if the input is x. If you put your customized function as the parameter, for example, "MyFancyFunction", the output might be some cell array of strings, which is not supported in Simulink. That is what the error message is about.
  6 comentarios
Frank
Frank el 19 de Dic. de 2011
As input signal to diff() I am using currently the simulation time (Clock).
I think Fangjun is right in Simulink diff just gets one value and from this vector it cant calculate the diff.
Thanks guys.
Fangjun Jiang
Fangjun Jiang el 19 de Dic. de 2011
Yes. It is particular related to the diff() function. I also did an example. Connect a Constant block to the MATLAB Fcn block with diff. If the Constant value is 1, it got the same error message. If the Constant is a vector signal like 1:5, it runs without problem.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Array and Matrix Mathematics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by