Modifying Selections with Get and Set in LiveLink for Matlab

Please login with a confirmed email address before reporting spam

Hello everyone,

I could retrieve information of selections with the "get" command (see following example with the model in the attachment).

model1=mphload('SupportSelectionExample1') model1 = COMSOL Model Object Name: SupportSelectionExample1.mph Tag: Model Identifier: root

model1.component.get('comp1').selection('sel16') ans = Geometry geom1: Dimension 3: Domains 4–5 Type: Explicit Tag: sel16 Operation: Explicit

However, I haven't been able to modify the setting under "Geometry" with LiveLink for Matlab. Could anybody help?

Best regards, Anton



1 Reply Last Post 2025年3月19日 GMT-4 10:52

Please login with a confirmed email address before reporting spam

Posted: 1 week ago 2025年3月19日 GMT-4 10:52

I found the solution by myself and place it here for anybody who needed it:

Load model:

model1=mphload('SupportSelectionExample1') model1 = COMSOL Model Object Name: SupportSelectionExample1.mph Tag: Model Identifier: root

Set selections with domain numbers:

model1.component.get('comp1').selection('sel21').set([8 14 15 17 19 22 23 24]) ans = Geometry geom1: Dimension 3: Domains 8, 14–15, 17, 19, 22–24 Type: Explicit Tag: sel21 Operation: Explicit

model1.component.get('comp1').selection('sel16').set([4 5 6 7]) ans = Geometry geom1: Dimension 3: Domains 4–7 Type: Explicit Tag: sel16 Operation: Explicit

Save under new name:

mphsave(model1,'SupportSelectionExample1set')

I found the solution by myself and place it here for anybody who needed it: Load model: >>model1=mphload('SupportSelectionExample1') model1 = COMSOL Model Object Name: SupportSelectionExample1.mph Tag: Model Identifier: root Set selections with domain numbers: >> model1.component.get('comp1').selection('sel21').set([8 14 15 17 19 22 23 24]) ans = Geometry geom1: Dimension 3: Domains 8, 14–15, 17, 19, 22–24 Type: Explicit Tag: sel21 Operation: Explicit >> model1.component.get('comp1').selection('sel16').set([4 5 6 7]) ans = Geometry geom1: Dimension 3: Domains 4–7 Type: Explicit Tag: sel16 Operation: Explicit Save under new name: >> mphsave(model1,'SupportSelectionExample1set')

Reply

Please read the discussion forum rules before posting.

Please log in to post a reply.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.