Set properties of a COM-server that take an argument
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Adeline
am 11 Aug. 2023
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;
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!