Set properties of a COM-server that take an argument
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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;
참고 항목
카테고리
Help Center 및 File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!