model.param.get does not return complex values

Thread index  |  Previous thread  |  Next thread  |  Start a new discussion

RSS FeedRSS feed   |   Email notificationsTurn on email notifications   |   3 Replies   Last post: November 28, 2011 6:15am UTC
Emi Kawamura

Emi Kawamura

November 27, 2011 10:43am UTC

model.param.get does not return complex values

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

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

November 27, 2011 7:55pm UTC in response to Emi Kawamura

Re: model.param.get does not return complex values

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

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Emi Kawamura

Emi Kawamura

November 27, 2011 9:20pm UTC in response to Ivar Kjelberg

Re: model.param.get does not return complex values


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

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

November 28, 2011 6:15am UTC in response to Emi Kawamura

Re: model.param.get does not return complex values

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

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse


Rules and guidelines