Thread Subject: error with mpower

Subject: error with mpower

From: Jumi

Date: 28 Oct, 2009 16:33:22

Message: 1 of 4

I don't understand why I am getting an error when I run this. It says that there is an error with mpower... that the matrix must be a square. but here... I am just trying to raise a scalar to a scalar power...

note... both Pa and Pe are scalars

Pa = absorbed/ntrials;
Pe = emitted/ntrials;

Teff = input('enter effective temperature in K');
A = 0.33; % albedo of Earth
S = 1367; % solar constant
Tg4 = (1+Pa/Pe)*Teff^4;
Tg = Tg4^(1/4); % ground temp
Ti4 = (Pl/(2*Pe*opl))*Teff^4;
Ti = Ti4^(1/4); % temp of top layer


the only way I don't get an error is if I use .^ for Tg and Ti. But I want the output for Ti and Tg to be scalars, not arrays. What am I doing wrong?

Thanks =)

Subject: error with mpower

From: Peter Brooks

Date: 28 Oct, 2009 17:01:18

Message: 2 of 4

Jumi <plopony@hotmail.com> wrote in message <148229629.126692.1256747632594.JavaMail.root@gallium.mathforum.org>...
> I don't understand why I am getting an error when I run this. It says that there is an error with mpower... that the matrix must be a square. but here... I am just trying to raise a scalar to a scalar power...
>
> note... both Pa and Pe are scalars
>
> Pa = absorbed/ntrials;
> Pe = emitted/ntrials;
>
> Teff = input('enter effective temperature in K');
> A = 0.33; % albedo of Earth
> S = 1367; % solar constant
> Tg4 = (1+Pa/Pe)*Teff^4;
> Tg = Tg4^(1/4); % ground temp
> Ti4 = (Pl/(2*Pe*opl))*Teff^4;
> Ti = Ti4^(1/4); % temp of top layer
>
>
> the only way I don't get an error is if I use .^ for Tg and Ti. But I want the output for Ti and Tg to be scalars, not arrays. What am I doing wrong?
>
> Thanks =)

You're using variables "opl" and "Pl" without having defined them. Assuming that they are both scalars, the code you've posted works fine. Are you positive that Pa and Pe are both scalar quantities?

Subject: error with mpower

From: Steven Lord

Date: 28 Oct, 2009 17:03:37

Message: 3 of 4


"Jumi" <plopony@hotmail.com> wrote in message
news:148229629.126692.1256747632594.JavaMail.root@gallium.mathforum.org...
>I don't understand why I am getting an error when I run this. It says that
>there is an error with mpower... that the matrix must be a square. but
>here... I am just trying to raise a scalar to a scalar power...
>
> note... both Pa and Pe are scalars
>
> Pa = absorbed/ntrials;
> Pe = emitted/ntrials;
>
> Teff = input('enter effective temperature in K');

What do you/the user enter here? Is Teff a scalar or a nonscalar? My guess
is that it's nonscalar. To check this, put a breakpoint on this line in
your code and step through the rest of the execution, making sure on each
line that the variables with which you're working have the sizes you expect.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: error with mpower

From: Bobby Cheng

Date: 28 Oct, 2009 19:52:08

Message: 4 of 4

Unlike *, ^ does not do scalar expansion.

So .^ is the way to go for elementwise power.

---Bob.

"Steven Lord" <slord@mathworks.com> wrote in message
news:hc9tfo$hpm$1@fred.mathworks.com...
>
> "Jumi" <plopony@hotmail.com> wrote in message
> news:148229629.126692.1256747632594.JavaMail.root@gallium.mathforum.org...
>>I don't understand why I am getting an error when I run this. It says that
>>there is an error with mpower... that the matrix must be a square. but
>>here... I am just trying to raise a scalar to a scalar power...
>>
>> note... both Pa and Pe are scalars
>>
>> Pa = absorbed/ntrials;
>> Pe = emitted/ntrials;
>>
>> Teff = input('enter effective temperature in K');
>
> What do you/the user enter here? Is Teff a scalar or a nonscalar? My
> guess is that it's nonscalar. To check this, put a breakpoint on this
> line in your code and step through the rest of the execution, making sure
> on each line that the variables with which you're working have the sizes
> you expect.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ:
> http://matlabwiki.mathworks.com/MATLAB_FAQ
>

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com