How do I get ismember() to accept an unsorted vector in code within a MATLAB function block?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Nancy
el 20 de Dic. de 2014
Respondida: Nancy
el 22 de Dic. de 2014
I'm trying to create a subsystem that returns the index of a given value within an array that is defined in the MATLAB workspace. When I input the vector to the MATLAB function block, I get an error message that the input vector is unsorted (with an arrow pointing to the call to ismember() in the code). But having an unsorted vector as the second operand is the point--I'm trying to get the index of a particular value in an unsorted vector.
So for example, in the attached models, if FiringOrder is defined in the MATLAB workspace as [1,4,2,6,3,5], I want to see 5 for y. (I've got two ways here of reading in the array, which seem to be equivalent--they both give the same error.) The code works without problem directly in MATLAB.
The exact error message is "Call to MATLAB function aborted: The second operand is not sorted in ascending order. Use SORT first.", with the arrow pointing to the line calling ismember().
I expect it's something simple--this is the first time I'm using the MATLAB function block. Can someone help me here? Thanks.
BTW, I'm running MATLAB R2014b.
3 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Functions 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!