Question

In the next exercises, we consider square n X n matrices; I is the identity matrix (In MATLAB eye (n) gives a square n by n matrix). If ex is the column unit vector which components are all Os except the kth component which is equal to 1, i.e., 이.e1 = 101 0 then the identity matrix I is such that: 10 000 ei = [100 01T, , el 1000 11T. 0 0 T 0 0 1 To generate in MATLAB the unit (colunn) vector er e R, one may uses the sequence of commands: I-eye (n);e(1)-I:,i) Exercise 1.5 Let A Rnxn, r E Rk. Find the first column of using a sequence of GAXPYs operations

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The column version of GAXPY must be applied here.(Since x is a column vector according to the definition). The following code does this.

clc
close all
clear all


%Input matrix of size of n x n
% A = [1 2 3;4 5 6;7 8 9];
A = ones(5,5)
% A=round(20*rand(5,5))   % RAndom A generation
n=size(A,2);
%generation of x; x is a column vector
%x1 = I(:,1)===> x1 = [1 0 0]'
%Each column of I represents x1,x2....xn

I=eye(n)

%computing (A-xkI) terms using GAXPY column version
for i=1:n
    for j=1:n
        x=I(:,i); %each time column of I is stored in x as in your question
        I_up{i}=A-x(j)*I; %single term computation
    end
end

%multiplication of obtained matrices for getting M
M=1;
for i=1:length(I_up)
    M=M*I_up{i};
end

%first column of M
disp('First Column of M')
disp(M(:,1))

Result of the code:

MATLAB 7.8.0 File Edit Debug Parallel Desktop Window Help 。e3 |美9a喒つ 都ゴヨ1 @ Current Directory:CAUsersUSERDocuments\MATLAB Shortcuts a How to AddWhats New A - Square Matrix 0 100Each column of I is:x ist Column o S00 500 S00 500 S00 result 兵>>

Add a comment
Know the answer?
Add Answer to:
In the next exercises, we consider square n X n matrices; I is the identity matrix...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT