This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: carried out by the repitition loop A=randint(N,N,[1,9]); % Generate the first NbyN matrix containing random integers between 1 and 9. B=randint(N,N,[1,9]); % Generate the second NbyN matrix containing random integers between 1 and 9. pause % Matrix multiplication method A: using the builtin matrix multiplication operator. tic % saves the current time for count=1:repeat_n_times % repeat n times in the repitition loop C1=A*B; end toc % Measures the elapsed time C1 % Print out C1 disp( 'method A finished' ) pause %Matrix multiplication method B: using the 'repetition loop' %******************************************** tic % saves the current time for count=1:repeat_n_times % repeat n times in the repitition loop for i=1:N for j=1:N for k=1:N t(k+1)=t(k)+A(i,k)*B(k,j); end C2(i,j)=t(N+1); end end end toc % Measures the elapsed time %******************************************** C2 % Print out C2 disp( 'method B finished' )...
View Full
Document
 Spring '08
 NILSON

Click to edit the document details