Got Questions? Get Answers.
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:
solving a matrix

Subject: solving a matrix

From: Ender

Date: 4 Mar, 2010 05:55:10

Message: 1 of 3

I am trying to solve this matrix in MATLAB:

(A-q*I)*y=x for y

I know the matrix A, the Identity matrix I, and the vector x. I also know the value of q.
A = [2,-3,6;0,3,-4;0,2,-3]
q = -3.5
x = [-1,0,1]

I did not know how to write the code for (A-q*I) so I wrote a variable called A_q
A_q = [2-q,-3,6;0,3-q,-4;0,2,-3-q];

I want to solve the equation for y. I do not know how to write the line of code that does this.

The answer is:
[0.6182;-0.3556;-0.5778]

Thanks,
Ender

Subject: solving a matrix

From: Bruno Luong

Date: 4 Mar, 2010 07:20:23

Message: 2 of 3

"Ender " <jr147@msstate.edu> wrote in message <hmnhvu$hd0$1@fred.mathworks.com>...
> I am trying to solve this matrix in MATLAB:
>
> (A-q*I)*y=x for y
>
> I know the matrix A, the Identity matrix I, and the vector x. I also know the value of q.
> A = [2,-3,6;0,3,-4;0,2,-3]
> q = -3.5
> x = [-1,0,1]
>
> I did not know how to write the code for (A-q*I) so I wrote a variable called A_q
> A_q = [2-q,-3,6;0,3-q,-4;0,2,-3-q];
>
> I want to solve the equation for y. I do not know how to write the line of code that does this.
>
> The answer is:
> [0.6182;-0.3556;-0.5778]
>

help NULL

Subject: solving a matrix

From: Stefan

Date: 4 Mar, 2010 07:48:24

Message: 3 of 3

Try this:

y=(A-q*eye(size(A)))\x'

y =

   -0.6182
    0.3556
    0.5778

Check:

(A-q*eye(size(A)))*y-x'


ans =

  1.0e-015 *

   -0.4441
         0
   -0.1110

Regards,
Stefan




Ender " <jr147@msstate.edu> wrote in message <hmnhvu$hd0$1@fred.mathworks.com>...
> I am trying to solve this matrix in MATLAB:
>
> (A-q*I)*y=x for y
>
> I know the matrix A, the Identity matrix I, and the vector x. I also know the value of q.
> A = [2,-3,6;0,3,-4;0,2,-3]
> q = -3.5
> x = [-1,0,1]
>
> I did not know how to write the code for (A-q*I) so I wrote a variable called A_q
> A_q = [2-q,-3,6;0,3-q,-4;0,2,-3-q];
>
> I want to solve the equation for y. I do not know how to write the line of code that does this.
>
> The answer is:
> [0.6182;-0.3556;-0.5778]
>
> Thanks,
> Ender

Tags for 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