How do I get ismember() to accept an unsorted vector in code within a MATLAB function block?
1 回表示 (過去 30 日間)
古いコメントを表示
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.
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!