Error: No method 'Set' with matching signature found for class 'System.String[]'.

Can somebody explain an error please? Resulting from this code.
Fluid1_Data = NET.createArray('System.String',5);
Fluid1_Data.Set(0, 'Water'); % First data input
"etc." % 4 more inputs
The code creates a string to be used as an input to a calculation referencing a DLL file in C#.
The arrays can be created and calculations works when using the command window, but not when created as an S-function.

 채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 18일

0 개 추천

Part of the problem is that the language accepted for any of the acceleration modes for Simulink is both a restricted subset and requires additional mark-up not normally required. And if code generation to HDL is being used then the subset is further restricted.
This might not be the entire problem though.

댓글 수: 3

Cheers Walter, I ran the simulation in normal mode with the same error.
The DLL file expects 3 arrays in the form of System.Strings, I got the method from http://uk.mathworks.com/help/matlab/matlab_external/create-net-collections.html.
Having tried this in the command window, the System.Strings are created in the workspace. Then the calculation function works giving outputs.
Could you suggest a way to check which part of the syntax is not correct, or what I should add in the s function to work?
Have you experimented with using it in a MATLAB Function Block?
Are you using a Level 1 S Function, or a Level 2 S Function? It has been a fair number of years since I read about Level 2 S Functions so I am not at all sure about the restrictions; the questions here tend to be about MATLAB Function Block so those I know somewhat better.
It's a Level 2 S function. I created a separate m file called Create_Arrays and referenced it inside of the larger calculation. It works now but I can't explain why yet. I'll post a description if I find out where the error came from.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

질문:

2016년 10월 18일

댓글:

2016년 10월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by