MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and proprietary programming language developed by MathWorks. It still amazes me how easily scientific calculations can be done with the help of this tool.
The code is self explanatory. Running the code in Matlab 2016b, a message similar to the following will be shown on Command Window.
Sometimes you might want to know, how fast or slow is the piece of code you have written. This is very easy with matlab. The built-in function tic and toc can be used for this.
See the example below.
tic %add this
statement just before the start of the code you want to check
a=rand(100); %create 100
by 100 random matrix.
for i=1:10 %repeat 10 times
a=a*a;
%matrix multiplication
end
toc %add this
statement just after the end of the code you want to check
Elapsed time is 0.045149 seconds.
Pretty simple isn't it. :)
Comments
Post a Comment