Question

1. What does the following code compute? Explain what operation the third line is per- forming b = zeros(m, 1); for i = 1:m b

Using MATLAB please.

A = rand(m,n)

x = rand(n,1)

b = A * x

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

`Hey,

Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.

a)

Third line is basically assigning value at index i in b vector to the value ith row of A multiplied by column vector x

b)

clc

clear all

close all

format long

m=3;

n=4;

A = rand(m,n);

x = rand(n,1);

tic;

b = A * x

disp('time required for code in last program')

t1=toc

tic;

b=zeros(m,1);

for i=1:m

b(i)=A(i,:)*x;

end

disp('time required for code given in question')

t2=toc

4 5 6 7 - 8 - 9 10 11 12 13 - 14 - 15 - 16 17 18 19 - 20 format long m=3; n=4; A = rand(m, n); x = rand(n,1); tic; b = A * X

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Using MATLAB please. A = rand(m,n) x = rand(n,1) b = A * x 1. What...
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