Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

How to assign a parameter to each grid cell by COMSOL with MATLAB?

Please login with a confirmed email address before reporting spam

For example, in Darcy model, in order to realize heterogeneity for model, different permeability parameters which may satisfy a kind of distribution function should be assigned to each grid cell. How to call the grid information to assign value by COMSOL with MATLAB before calculation. In attach file, 'heterogeneity1.m' is a m. file for a simple PDE model and parameter k is permeability metioned above. The grid information is give in 'mesh.m'. Thanks for your attention!


3 Replies Last Post 15.08.2016, 20:32 GMT-4
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 14.07.2016, 03:08 GMT-4
Hi

In order to use measured data in a Comsol model you can use an Interpolation Table. It doesn't matter if you have access to Matlab or not the procedure is the same and I recommend that you use the Comsol Desktop to set up your model.

You can read in your data for the interpolation table from a file, but you have to reformat your data to a file format that can be read by Comsol. The data formats are described in the Programming Reference Manual (previously called the COMSOL API Reference Manual).

We introduced a new Matlab function in Comsol 5.0 called mphinterpolationfile that can be used to generate these data file from Matlab data.

--
Lars Gregersen
Comsol Denmark
Hi In order to use measured data in a Comsol model you can use an Interpolation Table. It doesn't matter if you have access to Matlab or not the procedure is the same and I recommend that you use the Comsol Desktop to set up your model. You can read in your data for the interpolation table from a file, but you have to reformat your data to a file format that can be read by Comsol. The data formats are described in the Programming Reference Manual (previously called the COMSOL API Reference Manual). We introduced a new Matlab function in Comsol 5.0 called mphinterpolationfile that can be used to generate these data file from Matlab data. -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 22.07.2016, 07:19 GMT-4
Hi

Thanks a lot!
What you said is a solution for this question. I have written a MATLAB function that is similar to the stair function to assign a parameter to each grid cell only for rectangular element. However, the parameter only be assigned each grid node.

Best wish
Hi Thanks a lot! What you said is a solution for this question. I have written a MATLAB function that is similar to the stair function to assign a parameter to each grid cell only for rectangular element. However, the parameter only be assigned each grid node. Best wish

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 15.08.2016, 20:32 GMT-4
This question is similar to get and update each element's material parameter. I have the same problem.
This question is similar to get and update each element's material parameter. I have the same problem.

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.