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.

 Accepted Answer

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 Comments

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.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Mobile in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!