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 件のコメント

andrew mccahey
andrew mccahey 2016 年 10 月 18 日
編集済み: andrew mccahey 2016 年 10 月 18 日
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?
Walter Roberson
Walter Roberson 2016 年 10 月 18 日
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.
andrew mccahey
andrew mccahey 2016 年 10 月 19 日
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 ExchangeStartup and Shutdown についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by