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.

Manipulating data in tables

Please login with a confirmed email address before reporting spam

Hi everyone,

Such a simple question it seems but I just can't find the answer.
How do I manipulate the data in tables? E.g. how to add a column to the table which is abs()^2 of another column?
Or how to take a column from one table and add it to a column in another table etc. Are there any commands
for that within Comsol GUI or do I necessarily have to export table data in Excell, etc.?

This question has been asked here but no clear answer followed, though it was mentioned that columnwise table operations can be done easily..

Many thanks in advance!
Anton.

5 Replies Last Post 21 avr. 2014, 06:35 UTC−4
Gunnar Andersson COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 24 mars 2014, 03:33 UTC−4
There is no support for this kind of operation on tables. Sometimes it's possible to work around this by evaluating several times into a table with different expressions.
There is no support for this kind of operation on tables. Sometimes it's possible to work around this by evaluating several times into a table with different expressions.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 24 mars 2014, 04:41 UTC−4
Dear Gunnar,

Thanks for the clear answer. I began to suspect as much.
Unfortunately Line Integration under Derived Values lets me edit only the integrand expression. I couldn't find a way to do mathematical operations on the integration result.

I am aware that I can define a global variable using the "intop" integration operator, and then use Global Evaluation under Derived Values for post-processing. But the "intop" operator doesn't work for me because I need to calculate an overlap integral between a mode field defined on one edge and the field profile defined on the other. So I use two Cut Line 2D data sets - one line for the the mode and one line for the field profile edges. Then I join them together by a Join data set and apply Line Integration to something like "data1(ewbe.Ey)*data2(ewbe.Hz)". Seems to work, but how do I get abs(integration result)^2? Do I really have to export data to Excell, etc. for such a simple thing?

My Line Integration subnode has a tag "int1". I tried to use the tag to assign the integration result to a variable for further processing but I couldn't. Is it also impossible?

Many thanks for the feedback!

Dear Gunnar, Thanks for the clear answer. I began to suspect as much. Unfortunately Line Integration under Derived Values lets me edit only the integrand expression. I couldn't find a way to do mathematical operations on the integration result. I am aware that I can define a global variable using the "intop" integration operator, and then use Global Evaluation under Derived Values for post-processing. But the "intop" operator doesn't work for me because I need to calculate an overlap integral between a mode field defined on one edge and the field profile defined on the other. So I use two Cut Line 2D data sets - one line for the the mode and one line for the field profile edges. Then I join them together by a Join data set and apply Line Integration to something like "data1(ewbe.Ey)*data2(ewbe.Hz)". Seems to work, but how do I get abs(integration result)^2? Do I really have to export data to Excell, etc. for such a simple thing? My Line Integration subnode has a tag "int1". I tried to use the tag to assign the integration result to a variable for further processing but I couldn't. Is it also impossible? Many thanks for the feedback!

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 24 mars 2014, 15:36 UTC−4
Hi Anton

you have the Matlab or Excel LiveLink to easily manipulate the results in tables, unfortunately (and I have asked this for some time so I suspect it will come once, COMSOL are proactive on useful suggestions ;) today you have no way to access a table value by an "index" A1, C15 ... as for EXCEL, it's probably patented by MS anyhow, = how to make $/€ on Einstein's indexing of lists ...)
But ,as you say, you do have a column wise operation to apply to all columns of a table (but it supresses the individual values, so you must call your Derived Values twice, if you also nee the individual values too ...

I find that COMSOL's developer have done a great job on the top nodes of the model tree, over the last years, but they have forgotten somewhat to concentrate on the bottom ones, the one we end user and engineers use to get reports and graphs to sell our business, hence to get cash to buy more COMSOL modules ...

So I hope for next release ... :)
--
Good luck
Ivar
Hi Anton you have the Matlab or Excel LiveLink to easily manipulate the results in tables, unfortunately (and I have asked this for some time so I suspect it will come once, COMSOL are proactive on useful suggestions ;) today you have no way to access a table value by an "index" A1, C15 ... as for EXCEL, it's probably patented by MS anyhow, = how to make $/€ on Einstein's indexing of lists ...) But ,as you say, you do have a column wise operation to apply to all columns of a table (but it supresses the individual values, so you must call your Derived Values twice, if you also nee the individual values too ... I find that COMSOL's developer have done a great job on the top nodes of the model tree, over the last years, but they have forgotten somewhat to concentrate on the bottom ones, the one we end user and engineers use to get reports and graphs to sell our business, hence to get cash to buy more COMSOL modules ... So I hope for next release ... :) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 25 mars 2014, 08:50 UTC−4
Dear Ivar,

Thank you so VERY-VERY MUCH - not only for this but for hundreds of your other valuable posts here! :)
Actually you have already helped me out several times. And for sure many other users are finding answers to their questions in your posts all the time. :)

As for managing data in tables - that's really not a big thing - I can do what I want in Excell, Matlab, Origin, whatever.. A bigger challenge for me was to find a way to calculate an overlap integral between field profiles defined on different boundaries. Although I can do it externally as well, I thought there must be an easy way among Comsol's numerous integration capabilities. What I came up with - using two Cut Line data sets then joining them with a Join data sets and applying Line Integration is not perhaps the most elegant solution, and what's more it gives strange results sometimes. I'll verify it further.

In the meantime do yo think there are easier ways to do that? I came across 'spatial at' operator in the manual, but somehow it returns slightly different field profiles (with artifacts) from what I have on my boundaries..







Dear Ivar, Thank you so VERY-VERY MUCH - not only for this but for hundreds of your other valuable posts here! :) Actually you have already helped me out several times. And for sure many other users are finding answers to their questions in your posts all the time. :) As for managing data in tables - that's really not a big thing - I can do what I want in Excell, Matlab, Origin, whatever.. A bigger challenge for me was to find a way to calculate an overlap integral between field profiles defined on different boundaries. Although I can do it externally as well, I thought there must be an easy way among Comsol's numerous integration capabilities. What I came up with - using two Cut Line data sets then joining them with a Join data sets and applying Line Integration is not perhaps the most elegant solution, and what's more it gives strange results sometimes. I'll verify it further. In the meantime do yo think there are easier ways to do that? I came across 'spatial at' operator in the manual, but somehow it returns slightly different field profiles (with artifacts) from what I have on my boundaries..

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 21 avr. 2014, 06:35 UTC−4
In reply to my own question (for the sake of future generations of desperate newbies ;)

Operations like overlap integrals between field profiles defined on different boundaries seem to be most easily done using component coupling operators, e.g. linear extrusion. In this way you can map a quantity defined on one boundary onto the other boundary, thus making them both available for calculations on a single boundary.

Good luck!

In reply to my own question (for the sake of future generations of desperate newbies ;) Operations like overlap integrals between field profiles defined on different boundaries seem to be most easily done using component coupling operators, e.g. linear extrusion. In this way you can map a quantity defined on one boundary onto the other boundary, thus making them both available for calculations on a single boundary. Good luck!

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.