% with diary, everything that is typed in % will go to the file, comments start with % diary off % close the file % we continue our diary.. % as a complement to diary, which just creates % a text file, only suitable for reading, % is the "save" command a = rand(2,2) a = 0.9501 0.6068 0.2311 0.4860 b = rand(2,1) b = 0.8913 0.7621 % a and b define a linear system a*x = b, % we solve it via the backslash operator: x = a\b x = -0.0912 1.6115 % to check the quality of the solution, % we compute the norm of the residual vector r = b - a*x r = 1.0e-015 * 0 0.1110 format long r r = 1.0e-015 * 0 0.11102230246252 format long e r r = 0 1.110223024625157e-016 % the default working with numbers is not % the software driven arithmetic of Maple % but standard double floating-point % Let us now try to save our work: save matlec1data % the file created by save is not meant % to be read by the user, but is only meant % to store the data for later use by MATLAB who Your variables are: a b r x a a = Column 1 9.501292851471754e-001 2.311385135742878e-001 Column 2 6.068425835417866e-001 4.859824687092997e-001 % who lists the variables in use, % typing just a name of a variable shows % its value clear who % we can recover the data via the load load matlec1data % the residual r computed via the norm % measures the accuracy of the numerical solution who Your variables are: a b r x r r = 0 a a = Column 1 8.162057091619634e-001 9.770923548415121e-001 Column 2 2.219080795405284e-001 7.036836674057537e-001 format short e a a = 8.1621e-001 2.2191e-001 9.7709e-001 7.0368e-001 b b = 5.2206e-001 9.3290e-001 x x = 4.4849e-001 7.0298e-001 cd .. % the save command creates a file of type % "mat", automatically added as extension % to the filename given as argument to save % With a script, a file with extension .m % we store the commands we want to execute. diary off