Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Matrix arithmetic operators

Subject: Matrix arithmetic operators

From: Ender

Date: 7 Jul, 2011 21:29:11

Message: 1 of 3

I am having trouble getting MATLAB to solve this equation. The error that I am getting is this:
??? Error using ==> mpower
Matrix must be square.

I would like a 11x1 matrix, but I am not sure what arithmetic operations I need to specify to make the result an 11x1 matrix

Q_es1_ = pi/4*(A/B)^2*Ln(1+C/D1_)

A = 1x1
B = 11x1
C = 11x1
D1_ = 1x1

I want to compare (e.g. plot) this variable with another 11x1 variable as a function of another variable which is 11x1


--Ender--

Subject: Matrix arithmetic operators

From: James Tursa

Date: 7 Jul, 2011 21:51:25

Message: 2 of 3

"Ender " <jr147@msstate.edu> wrote in message <iv58f7$fjf$1@newscl01ah.mathworks.com>...
> I am having trouble getting MATLAB to solve this equation. The error that I am getting is this:
> ??? Error using ==> mpower
> Matrix must be square.
>
> I would like a 11x1 matrix, but I am not sure what arithmetic operations I need to specify to make the result an 11x1 matrix
>
> Q_es1_ = pi/4*(A/B)^2*Ln(1+C/D1_)
>
> A = 1x1
> B = 11x1
> C = 11x1
> D1_ = 1x1
>
> I want to compare (e.g. plot) this variable with another 11x1 variable as a function of another variable which is 11x1
>
>
> --Ender--

The operators *, /, ^ etc are matrix operations. To operate element-wise, as you seem to want, put a dot in front of them. e.g.,

 Q_es1_ = pi/4*(A./B).^2.*Ln(1+C./D1_)

James Tursa

Subject: Matrix arithmetic operators

From: dpb

Date: 7 Jul, 2011 21:58:33

Message: 3 of 3

On 7/7/2011 4:29 PM, Ender wrote:
> I am having trouble getting MATLAB to solve this equation. The error
> that I am getting is this: ??? Error using ==> mpower
> Matrix must be square.
>
> I would like a 11x1 matrix, but I am not sure what arithmetic operations
> I need to specify to make the result an 11x1 matrix
>
> Q_es1_ = pi/4*(A/B)^2*Ln(1+C/D1_)
>
> A = 1x1
> B = 11x1
> C = 11x1
> D1_ = 1x1
>
> I want to compare (e.g. plot) this variable with another 11x1 variable
> as a function of another variable which is 11x1
...

Not sure but suspect it's a language thing but what do you mean "solve"
here? I'm guessing "evaluate the expression and store in the variable
Q_es1" is the objective instead of "solve"...

If so, you want the "dot" operators that work on an element-by-element
basis.

Q_es1_ = pi/4.*(A./B).^2.*log(1+C./D1_);

You _can_ get away w/o the ./ in the argument to log() as you can always
multiply or divide _by_ a constant.

--

Tags for this Thread

No tags are associated with this thread.

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.

Contact us