필터 지우기
필터 지우기

Set properties of a COM-server that take an argument

조회 수: 1 (최근 30일)
Stefan
Stefan 2023년 7월 17일
댓글: Stefan 2023년 8월 11일
Hi,
I started to work with a COM-server, which provides some custom simulation capabilities. In principle, the underlying program has a GUI but for some tasks, using it is relatively laborious. Therefore, I want to operate it through MATLAB.
For the simulation routine, I have to change some predefined properties to new values. Most of them can be easily changed with for example:
COMServ=actxserver('server.name');
set(COMServ,"tolerance",1.0e-05)% or COMServ.tolerance=1.0e-05; etc.
But some of the properties e.g. 'fit_parameter_value' take an argument and are therfore handled in MATLAB as methods. For example, in fit_parameter_value(k) multiple parameters are stored (k=1,2,3...). Reading them is no issue as several alternatives work:
COMServ.fit_parameter_value(k);
fit_parameter_value(COMServ,k);
invoke(COMServ,'fit_parameter_value',k)
But I am unfortunately not able to set new values (maybe because I am using the wrong syntax). Neither of the following seems to work for me:
COMServ.fit_parameter_value(k)=newValue; %Unrecognized property 'fit_parameter_value' for class 'COM.server_name'.
fit_parameter_value(COMServ,k)=newValue; %Unable to use a value of type COM.server_name as an index.
invoke(COMServ,'fit_parameter_value',k)=newValue;%Unable to use a value of type COM.server_name as an index.
What would be the correct way to set these properties?
Thank you.

답변 (1개)

Adeline
Adeline 2023년 8월 11일
You can change the property values by assigning the existing values to a handle and updating the property values through it.
For Example:
COMServ = actxserver('Matlab.Application'); % Create a server
ch = COMServ.interfaces; % Create a handle for the re. property
ch(1) = {'IMLApp'}; % Assign a value of choice to the property
In your case the following syntax can be followed:
MyHandle = COMServ.fit_parameter_value;
MyHandle(k) = newValue;
  댓글 수: 1
Stefan
Stefan 2023년 8월 11일
Hi,
Unfortunately, already creating the handle does not work as input parameters are still expected:
MyHandle = COMServ.fit_parameter_value;
--> Incorrect number or types of inputs or outputs for function 'fit_parameter_value'.
I contacted Mathworks Support regarding this issue a few days ago and it seems that it is not possible to set this due to COM limitations. They suggested using a .NET interface if possible.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by