Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4800 220-003: Biomedical Computing In Class Assignment 4 Make sure to comment yo

ID: 3790507 • Letter: 4

Question

4800 220-003: Biomedical Computing In Class Assignment 4 Make sure to comment your code! Due date on Springboard Assignments) Problem 5 (a) Recall that the multiplication of two matrices are defined as the following Baci [A]mn With correct dimensions, MATLAB operator will give us the flexibility of doing these types of multiplications. Now, let us assume that this feature is not available in MATLAB In other words, let assume that MATLAB can be used only for two returns values. Use for loop and write program that receives two matrices as inputs and a according the product of them as its output. If the dimensions of the matrices do not match to the multiplication rule, the function should output an error message. (b) Repeat part (a) for MATLAB (ie. write a program that does the job of the MAT. LAB operator). Compare the elapsed time that it takes to run this program vs. simply using the or operators. Experiment with a variety of conditions (different matrix sizes, etc) and com- ment on the differences in efficiency. This problem is worth 10 points (5 points for each part).

Explanation / Answer

prompt = 'Enter A matrix row ';
m = input(prompt)
prompt = 'Enter A matrix col ';
p = input(prompt)
prompt = 'Enter B matrix row ';
q = input(prompt)
prompt = 'Enter B matrix col ';
r = input(prompt)

if p!=q
break;
  
for i=1:m
for j=1:p
prompt = 'Enter value ';
A(i,j) = input(prompt)
end
end

for i=1:q
for j=1:r
prompt = 'Enter value ';
B(i,j) = input(prompt)
end
end


fprintf([repmat('%d ', 1, size(A, m*p)) ' '], A');
fprintf([repmat('%d ', 1, size(A, q*r)) ' '], B');

C = A*B;
fprintf([repmat('%d ', 1, size(C, m*r)) ' '], C');

for i=1:m
for j=1:r
D(i,j)=0
end
end


for i=1:m
for k=1:p
for j=1:r
D(i,k) = D(i,k) + A(i,j)*B(j,k);
end
end
end

fprintf([repmat('%d ', 1, size(D, m*r)) ' '], D');

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote