% Generate two 100x100 matrices with random contents: A=rand(100); B=rand(100); % Multiply the two matrices: AB=A*B; % Calculate the sum of the contents: sumAB=sum(AB(:)); % Save the AB and sumAB variables to the Matlab save file out.mat: save out.mat AB sumAB;