Using Matlab Use either MATLAB or OCTAVE to compute the product of two matrices
ID: 3786388 • Letter: U
Question
Using Matlab Use either MATLAB or OCTAVE to compute the product of two matrices two different ways: 1. By writing a code using nested for loops 2. Using vectorization and compare the computational complexity using the CPU times it takes on the computer you use. Specifically, the matrix in creditcard data that you can find on our server in the /home/public/MATH 4809S17/data folder is size 284807X31. 1. Load this data as the matrix C Now try calculating, and if possible, report how long (cPU time) it takes to do each of the following: 2. C'*C 3. C C'
Explanation / Answer
this is a sample code for A= 3x2 and B=2x3
A=[3 4; 5 2; 3 4];
B=[1 2 3 ; 4 5 6];
for i=1:3
for j=1:3
C(i,j)=sum( A (i,:)*B(:,j));
end
end
you can change the numbers,
replace 3 by 284807
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.