Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Assigning materials to domains from MATLAB

Please login with a confirmed email address before reporting spam

Dear COMSOL experts,

I am wondering how to assign materials to domains from a matlab script. For example, I create a block "my_block" with

>> model.geom('geom1').feature.create('my_block', 'Block');
>> ... % define the properties of block here

Then I create a material called "superconductor" with

>> model.material.create('superconductor');

Now, if I assign the "my_block" to material "superconductor" through COMSOL GUI and save the result as m file, the assignment will look like this:

>> model.material('superconductor').selection.set([1]);

How do I find out programatically the correspondence between "my_block" and the number 1 that I need to specify as the parameter to the last command.

Thanks in advance,
Andrey

3 Replies Last Post 10 feb 2017, 05:36 GMT-5
COMSOL Moderator

Hello Andrey Zhdanov

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 8 years ago 13 ott 2016, 07:19 GMT-4
Dear Andrey Zhdanov

I was stuck at the same point. Did you find the way to solve it

I would be glad if you let me know


Thanks
Prem
Dear Andrey Zhdanov I was stuck at the same point. Did you find the way to solve it I would be glad if you let me know Thanks Prem

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 9 feb 2017, 06:59 GMT-5
I was stuck also here, How could I program in Matlab like such sentence:

model.material('mat2').selection.set('block1');

instead of:

model.material('mat2').selection.set([1]);

For now my problem is that the domain [1] maybe not exact block 1 I wanted to select. I generated some random distribution of the geometries.

if anyone knows the answer, It would be a great help for my work.

best regards,
Guanda Yang
I was stuck also here, How could I program in Matlab like such sentence: model.material('mat2').selection.set('block1'); instead of: model.material('mat2').selection.set([1]); For now my problem is that the domain [1] maybe not exact block 1 I wanted to select. I generated some random distribution of the geometries. if anyone knows the answer, It would be a great help for my work. best regards, Guanda Yang

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 10 feb 2017, 05:36 GMT-5
Hi

This blog post should contain some useful information for you:
www.comsol.dk/blogs/automatically-handling-selections-comsol-multiphysics/

If you are still having problems then please send your model and M-files to support and we will try to help you.


--
Lars Gregersen
Comsol Denmark
Hi This blog post should contain some useful information for you: https://www.comsol.dk/blogs/automatically-handling-selections-comsol-multiphysics/ If you are still having problems then please send your model and M-files to support and we will try to help you. -- Lars Gregersen Comsol Denmark

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.