# Question: a matlab question which need to modify the code and...

###### Question details

A Matlab question, which need to modify the code and answer it, thanks!

% experimental parameters

N = 1000;

Nex = 50;

% three matrix types

% dense matrix (no zeros)

Md = randn(N,N);

% upper triangular

Mt = triu(Md);

% randomly row-exchanged upper triangular (these are tricky
array commands,

% but if you run a small sample, it is clear they do the right
thing)

idx=randperm(N);

Mp = Mt(idx,:);

% exact solution of all ones

x = ones(N,1);

% right-side vectors

bd = Md*x;

bt = Mt*x;

bp = bt(idx);

% dense test

tic

for jj = 1:Nex

xd = Mdd;

end

dense_time=toc;

% upper tri test

tic

for jj = 1:Nex

xt = Mtt;

end

tri_time=toc;

% permuted upper tri test

tic

for jj = 1:Nex

xp = Mpp;

end

perm_tri_time=toc;

%Computing avgerage solve times

avg_tri_time = tri_time/(Nex);

avg_perm_time = perm_tri_time/(Nex);

avg_dense_time = dense_time/(Nex);

% You may find the following code helpful for displaying the results % of this demo. type_times = {'Dense',avg_dense_time,'Upper Triangular', ... avg_tri_time,'permuted Upper Triangular', ... avg_perm_time}; fprintf(' ') fprintf('Estimated time for a %s matrix is %f seconds. ',type_times{:})