Please login with a confirmed email address before reporting spam
Posted:
2 decades ago
2009年9月28日 GMT-4 10:31
Hi Ozgur,
To access the numerical value of a constant at the command prompt I have used this line;
Tm = str2double(fem.const{find(strcmp(fem.const,'Tm'))+1});
Now if your value contains units I'm not aware of any command to handle this at matlab command prompt. I've simply avoided using units when scripting.
Cheers
Lars Ottar Kvale
Hi Ozgur,
To access the numerical value of a constant at the command prompt I have used this line;
Tm = str2double(fem.const{find(strcmp(fem.const,'Tm'))+1});
Now if your value contains units I'm not aware of any command to handle this at matlab command prompt. I've simply avoided using units when scripting.
Cheers
Lars Ottar Kvale
Please login with a confirmed email address before reporting spam
Posted:
2 decades ago
2009年9月28日 GMT-4 14:57
Hi Lars,
thank you for your response. I also heard from COMSOL support with the following suggestion which is very similar to your approach, FYI.
postglobaleval can be used (after model is updated with meshextend)
fem.xmesh = meshextend(fem);
.
.
Tm = postglobaleval(fem,{'Tm'});
Cheers,
Ozgur
Hi Lars,
thank you for your response. I also heard from COMSOL support with the following suggestion which is very similar to your approach, FYI.
postglobaleval can be used (after model is updated with meshextend)
fem.xmesh = meshextend(fem);
.
.
Tm = postglobaleval(fem,{'Tm'});
Cheers,
Ozgur
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:
2 decades ago
2009年9月28日 GMT-4 16:39
Hi there
for a slightly different case I have found an expression too, see the second last (of today) reply to Noemi' Petra's demand : "exporting data from the boundaries",
Use the search field, its the quickest to get there try the keyword strmatch
By the way the "Advanced Search" feature is quite nice to scan the discussions, and to find relevant data, there start to be quite a lot of knowledge in here
Good luck
Ivar
Hi there
for a slightly different case I have found an expression too, see the second last (of today) reply to Noemi' Petra's demand : "exporting data from the boundaries",
Use the search field, its the quickest to get there try the keyword strmatch
By the way the "Advanced Search" feature is quite nice to scan the discussions, and to find relevant data, there start to be quite a lot of knowledge in here
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Posted:
2 decades ago
2009年9月29日 GMT-4 14:27
Lars, Ivar and all:
I found that the postglobaleval method I quoted previously in this thread works only after the solution is evaluated, so I reverted back to parsing the values of interest directly from the fem.const structure using Matlab functions.
For your reference, I am including below a little function I wrote that trims the units and extracts the numerical value of the constant of interest.
-- In the Script file:
.
.
fem.const = {'Tm','0[degC]', ...
'dT','0.1[K]', ...
'ld','334[J/g]'};
.
.
% This is the function call to evaluate the numerical value of constant of interest from fem.const
constval=numconst('dT',fem.const)
.
.
-- and here is the function m file numconst.m
function strval=numconst(whichconst,femc)
mystr=(femc{find(strcmp(femc,whichconst))+1}); % find the string
% check if there is a bracket indicative of units
if isempty(strfind(mystr,'['))
strval=str2double(mystr); % no bracket found, convert to number directly
else
strval=str2double(mystr(1:strfind(mystr,'[')-1)); % trim the unit before conversion
% Note there is no unit conversion done here - must ensure that constant
% was already provided in the base units, or extend the function to detect
% units and carry out conversions
end
Lars, Ivar and all:
I found that the postglobaleval method I quoted previously in this thread works only after the solution is evaluated, so I reverted back to parsing the values of interest directly from the fem.const structure using Matlab functions.
For your reference, I am including below a little function I wrote that trims the units and extracts the numerical value of the constant of interest.
-- In the Script file:
.
.
fem.const = {'Tm','0[degC]', ...
'dT','0.1[K]', ...
'ld','334[J/g]'};
.
.
% This is the function call to evaluate the numerical value of constant of interest from fem.const
constval=numconst('dT',fem.const)
.
.
-- and here is the function m file numconst.m
function strval=numconst(whichconst,femc)
mystr=(femc{find(strcmp(femc,whichconst))+1}); % find the string
% check if there is a bracket indicative of units
if isempty(strfind(mystr,'['))
strval=str2double(mystr); % no bracket found, convert to number directly
else
strval=str2double(mystr(1:strfind(mystr,'[')-1)); % trim the unit before conversion
% Note there is no unit conversion done here - must ensure that constant
% was already provided in the base units, or extend the function to detect
% units and carry out conversions
end
Please login with a confirmed email address before reporting spam
Posted:
2 decades ago
2009年10月13日 GMT-4 16:33
Hello,
I have a similar question.
However, I'd like to access the value of constant when it is specified as an expression dependent on other constants.
For instance:
fem.const = {'you','60', ...
'me','sqrt(phi)};
How to get value of me instead of expression?
Thanks a lot for your help
Sorry, I already got it - postmax(fem,'me')
Hello,
I have a similar question.
However, I'd like to access the value of constant when it is specified as an expression dependent on other constants.
For instance:
fem.const = {'you','60', ...
'me','sqrt(phi)};
How to get value of me instead of expression?
Thanks a lot for your help
Sorry, I already got it - postmax(fem,'me')
Please login with a confirmed email address before reporting spam
Posted:
2 decades ago
2009年10月29日 GMT-4 06:25
Hi,
Interesting post. Do you guys have any recommendations for my very similar problem?
www.comsol.com/community/forums/general/thread/1343/
Regards,
Tom
Hi,
Interesting post. Do you guys have any recommendations for my very similar problem?
http://www.comsol.com/community/forums/general/thread/1343/
Regards,
Tom
Please login with a confirmed email address before reporting spam
Posted:
2 decades ago
2009年12月8日 GMT-5 09:41
...yet another problem related with this issue:
www.comsol.com/community/forums/general/thread/2069/
regards
Thomas
...yet another problem related with this issue:
http://www.comsol.com/community/forums/general/thread/2069/
regards
Thomas
Please login with a confirmed email address before reporting spam
Posted:
2 decades ago
2009年12月8日 GMT-5 09:41
...yet another problem related with this issue:
www.comsol.com/community/forums/general/thread/2069/
regards
Thomas
...yet another problem related with this issue:
http://www.comsol.com/community/forums/general/thread/2069/
regards
Thomas