Question

Bonus: Implement the following algorithm in MATLAB and submit your solution as an m-file. Input: two n x n matrices A, B, whe
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB program is given below:

Copy and paste from below to create .m file.

%%%

clc

clear all

n=input('Enter the value of n')
A=rand(2^n)
B=rand(2^n)
if n==0
C=A*B
else
for i=1:2^(n-1)
for j=1:2^(n-1)
A11(i,j)=A(i,j);
end
end
A11
for i=1:2^(n-1)
for j=2^(n-1)+1:2^(n)
A12(i,j-2^(n-1))=A(i,j);
end
end
A12
for i=2^(n-1)+1:2^(n)
for j=1:2^(n-1)
A21(i-2^(n-1),j)=A(i,j);
end
end
A21
for i=2^(n-1)+1:2^(n)
for j=2^(n-1)+1:2^(n)
A22(i-2^(n-1),j-2^(n-1))=A(i,j);
end
end
A22


for i=1:2^(n-1)
for j=1:2^(n-1)
B11(i,j)=B(i,j);
end
end
B11
for i=1:2^(n-1)
for j=2^(n-1)+1:2^(n)
B12(i,j-2^(n-1))=B(i,j);
end
end
B12
for i=2^(n-1)+1:2^(n)
for j=1:2^(n-1)
B21(i-2^(n-1),j)=B(i,j);
end
end
B21
for i=2^(n-1)+1:2^(n)
for j=2^(n-1)+1:2^(n)
B22(i-2^(n-1),j-2^(n-1))=B(i,j);
end
end
B22
end

I=(A11+A22)*(B11+B22)
II=(A21+A22)*B11
III=A11*(B12-B22)
IV=A22*(B21-B11)
V=(A11+A12)*B22
VI=(A21-A11)*(B11+B12)
VII=(A12-A22)*(B21+B22)

C11=I+IV-V+VII
C12=III+V
C21=II+IV
C22=I+III-II+VI

C=[C11 C12; C21 C22]

Add a comment
Know the answer?
Add Answer to:
Bonus: Implement the following algorithm in MATLAB and submit your solution as an m-file. Input: two...
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
  • ANSWER SHOULD BE NEAT CLEAN AND WELL EXPLAINED.HANDWRITTEN NEAT CLEAN,EACH STEP SHOULD BE EXPLAINED WELL Find...

    ANSWER SHOULD BE NEAT CLEAN AND WELL EXPLAINED.HANDWRITTEN NEAT CLEAN,EACH STEP SHOULD BE EXPLAINED WELL Find the M to meet the Lyapunov equation in (3.59) with What are the eigenvalues of the Lyapunov equation? Is the Lyapunov equation singular? Is the solution unique? Repeat Problem 3.31 for B- Ci- A1 -2 with two different C 3.7 Lyapunov Equation Consider the equation AM +MB C (3.59) where A and B are, respectively, n x n andmx m constant matrices. In order...

  • FUTURE VALUE ANNUAL DEPOSIT INTEREST RATE/GROWTH RA 4.00% ASSUMES DEPOSIT AT BEGINNING OF TIME-0 Compolunding Period...

    FUTURE VALUE ANNUAL DEPOSIT INTEREST RATE/GROWTH RA 4.00% ASSUMES DEPOSIT AT BEGINNING OF TIME-0 Compolunding Period TIME (YRS)DEPOSITEND OF YR FORMULATEXT SINGLE FORMULA FORMULATEXT END OF YR $43,167.12FV(SB$4,A27,-$B$3,,$B$6) 0 $1,500.00 $ 1,560.00 B8 (1+SBS4)AB6 1 $1,500.00 3,182.40(C8+B9)(1+SB$4)ASB$6 2 $1,500.00 $ 4,869.70 (C94B10)1+SB$4)n$B$ N THIS CASE THERE IS A DEPOSITY OF $1,500 EVERY YEAR. IN THE 3 $1,500.00 6,624.48 (C104811) (1 SB$4)ASB$6FV FUNCTION, WE ENTER THIS AS A NEGATIVE PAYMENT INSTEAD OF PV. 4 $1,500.00 $ 8,449.46 11+812)"(1+5B54)^SB$6 5 $1,500.00 10,347.44...

  • Question 1 a. Define the following matrices in a script file (M-file), ? = ( 8...

    Question 1 a. Define the following matrices in a script file (M-file), ? = ( 8 9 10 11; 23 9 16 15 ;11 12 3 6; 1 2 8 9 ) ? = ( 2 21 7 15; 12 4 8 22; 23 9 5 13; 23 4 21 22) ℎ = (4 9 12 15) b. Add suitable lines of codes to the M-file to do the following. Each of the following points should be coded in only...

  • Q2 YOU HAVE ANS THE QUESTION Hi Apps M Gmail YouTube S Solutions to Discret... S...

    Q2 YOU HAVE ANS THE QUESTION Hi Apps M Gmail YouTube S Solutions to Discret... S Solutions to A First... k Question 2 [5+5=10Marks] PDF Discrete_Str_Spring2020.pdf BS-AL(J,K) and BS-DS(N) | Open with a) Use valid argument forms to deduce the conclusion from the premises, giving a reason for each step i. a + b ii. CV d iii. ~d we iv. ~b v d V. ~d vi. ~AAC → f vii. h ve viii. :: f1h Instructions: 1. The final...

  • cope the code please thanks Write a MATLAB code to obtain the following. Keep your code...

    cope the code please thanks Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Generate a matrix "A" as follow. A= 16 6 8 2 10 18 12 14 4 I. II. Divide the matrix A by 2 and store the result in a matrix B. Combine matrices A & B to obtain the following matrix C. Also...

  • Homework 1- Merge Files: 1. Design a class named MergeFiles 1 Three file names are passed...

    Homework 1- Merge Files: 1. Design a class named MergeFiles 1 Three file names are passed as command-line arguments to MergeFiles as follows: java MergeFiles filel file2 mergedFile II. MergeFiles reads names stored in files file and file2 III. Merges the two list of names into a single list IV. Sorts that single list V. Ignores repetitions VI. Writes the sorted, free-of-repetitions list to a new file named mergedFile.txt VII. The names in all three files are stored as one...

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