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.

model.param.get does not return complex values

Please login with a confirmed email address before reporting spam

I set a parameter to a complex value by:

model.param.set('v1', 4.5+j*2)

However, when I try to access the parameter later by

model.param.get('v1')

All I get is

4.5

I am using comsol4.2a and matlab 2011a on a 64 bit linux machine.

Does the error occur when I am setting the parameter value or when I am accessing it.

In other words, is 'v1' correctly set to the complex value, and it is just the model.param.get that is not
working properly?

Or, is it model.param.set which is not setting 'v1' correctly?

I would appreciate any help.

Thank you,
Emi

3 Replies Last Post 2011年11月28日 GMT-5 01:15
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 2011年11月27日 GMT-5 14:55
Hi

I'm not sure you can retrieve the comlex value in one call, have you tried to recall twice with a real() and imag()

--
Good luck
Ivar
Hi I'm not sure you can retrieve the comlex value in one call, have you tried to recall twice with a real() and imag() -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2011年11月27日 GMT-5 16:20

No, the model.param.set does not work if you set a parameter to a complex number.

Currently, I am getting around this by turning the complex value into a string and
setting the parameter to that string.

Example:
v1 = 4.5+j*2.5
v1String = num2str(v1);
model.param.set('v1', v1String);

Then when I call
model.param.get('v1')

I get the correct value:
4.5+j*2.5

So, I guess to pass complex values to model.param.set, you need to convert it to a string first.

Regards,
Emi
No, the model.param.set does not work if you set a parameter to a complex number. Currently, I am getting around this by turning the complex value into a string and setting the parameter to that string. Example: v1 = 4.5+j*2.5 v1String = num2str(v1); model.param.set('v1', v1String); Then when I call model.param.get('v1') I get the correct value: 4.5+j*2.5 So, I guess to pass complex values to model.param.set, you need to convert it to a string first. Regards, Emi

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 2011年11月28日 GMT-5 01:15
Hi

Then I think it's worth to get that confirmed by "support". I find it somewhat astonishing, but OK, I hardly use matlab now with V4

--
Good luck
Ivar
Hi Then I think it's worth to get that confirmed by "support". I find it somewhat astonishing, but OK, I hardly use matlab now with V4 -- Good luck Ivar

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.