Question: *****Matlab****** Time a dense linear solve. Create an integer sequence of values Nvec between, say, N = 100 and the N max you found above.

*****Matlab******

Time a dense linear solve. Create an integer sequence of values Nvec between, say, N = 100 and the N max you found above. To generate this sequence, it is a good idea to use the logspace command. Using a for loop, loop over the entries N i of the sequence. In each pass through the loop, create a random matrix A of size N i N i , and a random right hand side vector b of size N i 1. Then, using tic and toc, time how long it takes to solve the system Ax = b using the backslash operator. Store this time as the i th entry in a vector lutimes. (d) On a log-log plot, plot the time values you found above (stored in lutimes) verses the N i in your sequence of N values. On the same set of axis, plot the curve of the theoretical time estimated by the operation count we discussed in class. Be sure to use the flop rate flops you computed above to get a time (in seconds) from an operation count. The two plots should be very close.

here is my code:

%3_6a Compute N for N x N matrix % Raspberry Pi 3 1GB RAM and 1.2GHz processor clear all clc Nmax = sqrt((2*1024^2)/8); %3_6b A = rand(Nmax); B = rand(Nmax); tic A*B; flops = (2/3)*toc^3; %theo_flops = ((1.2*10e9)/4); %theoretical flops Nvec = round(logspace(2, log10(Nmax),20)); for i = 1:length(Nvec) N = Nvec(i); A = rand(N,N); b = rand(N,1); tic; x = A\b; time(i) = toc; end lutimes = time(i); loglog(flops,lutimes)

I cannot get any data on my plot. Any suggestions?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!