Dear MATLAB Community,
I created a WebService with MATLAB. Now I want to run a specific function but this funtion strongly needs a data type "short". Parallel to MATLAB I created the same WebService and the same function in C# and there the function runs perfectly.
string elementName = "EL53";
string elementTypeName = "Line";
short portNr1 = 0;
bool isConnected = true;
client.SwitchElementAtPort(project, elementName, elementTypeName, portNr1, isConnected);
Above you can see the function in C#. Now my question is how can i create such a data type in MATLAB. I know that the data type "short" usually doenst exists in MATLAB and that it is equivalent to "int16()", so I tried this (see below), but sadly that didnt work.
portNr1 = int16(0)
Is there some kind of .dll I have to include to create a "short" variable ? What kind of possibilities do I have ?
Thanks in advance!! I am very grateful for any kind of help!! :)

댓글 수: 2

Rik
Rik 2018년 8월 2일
What is the Matlab code you're trying to run? 'it doesn't work' is too little detail to help you effectively.
OCDER
OCDER 2018년 8월 2일
Did you mean you CAN make an int16 number in matlab, but it fails when passing this to another function that requires short? Can we see THAT part, where you're passing in this argument to the function that's failing?

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

 채택된 답변

Guillaume
Guillaume 2018년 8월 3일

2 개 추천

Glad it's working. I'm still writing an answer as I want to clarify what's happening in matlab.
When you call a dll, COM, or .Net function matlab automatically translate compatible matlab types to the appropriate type as required by the function. You don't have to do this yourself. This means that if a function needs a short you can pass it any numerical type, a int16 of course, but double work just as well.

댓글 수: 1

Andre Becker
Andre Becker 2018년 8월 3일
Thanks for your comment! That makes it much clearer. You are totally right, I tried a double and it worked as well!

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

추가 답변 (1개)

Andre Becker
Andre Becker 2018년 8월 3일

0 개 추천

I am very sorry and ashamed. As I wanted to prepare the answer to your comments above I noticed a different, very little mistake. After correcting it the function ran perfectly. That means that MATLAB had no problem to read the "int16()" variable ... The mistake was that the function I was trying to run was void... but I gave it a variable as output, that didnt work.. In C# i used it correctly but didnt notice the slight difference in my MATLAB code.. I changed the code:
From this:
SwitchElementResult = cliente.SwitchElementAtPortByID(elementID,portNr,isConnected)
To this:
cliente.SwitchElementAtPortByID(elementID,portNr,isConnected)
Nevertheless I want to thank you for your support !

카테고리

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

질문:

2018년 8월 2일

댓글:

2018년 8월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by