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

Figure out what the following MATLAB code does (Notice that R = LT). If you put

ID: 3551650 • Letter: F

Question

Figure out what the following MATLAB code does (Notice that R = LT). If you put these instructions into a file named, say, zap.m, you can run the program by typing zap from the MATLAB command line. The functions randn, cputime. and chol are built-in MATLAB functions, so you can learn about them by typing help randn, etc. You might find it useful to type more on before typing help topic. Alternatively you can read about theme in MATLAB's help browser. Does the code produce reasonable values of ratio when you run it? What value would you expect in theory? Depending on the speed of the machine on which you are running MATLAB, you may want to adjust the initial value of n or the number of times the rep loop es executed.

Explanation / Answer

when i run in MATLAB i am getting ratio = 7.7652 1st time ,2nd time i get ratio=7.8712.


n=500;

for jay=1:4;

if jay>1;

oldtime=time;end

M=rand(n);

A=M'*M;

t=cputime;

for rep = 1:5

R=chol(A);

end

matrixsize=n;

time=cputime-t;

if jay>1;

ratio=time/oldtime;

end

n=2*n;

end

  

  

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