Translate

Tuesday, 26 February 2013

7 Awesome MATLAB tricks


MATLAB, for an engineer it's an indispensable resource, extremely useful and fun to use.
But there are also some cool tricks that are rarely known and fun to implement.

1.Batman Equation Curve in MATLAB


here is a code "xr = linspace(-7,7,1500);
yr = linspace(4.5,-4.5,1500);

x = repmat( xr , [ numel(yr) 1 ] );
y = repmat( yr' , [ 1 numel(xr) ] );

batman = (((x/7).^2.*sqrt(abs(abs(x)-3)./(abs(x)-3))+((y/3).^2) .*  ...
           sqrt(abs(y+(3*sqrt(33)/7))./(y+(3*sqrt(33)/7))))-1) .* ...
         (abs(x/2)-((3*sqrt(33)-7)/112).*(x.^2)-3+sqrt(1-(abs(abs(x)-2)-1).^2) - y) .* ...
         (9*sqrt(abs((abs(x)-1).*(abs(x)-0.75))./((1-abs(x)) .* (abs(x)-0.75)))-8*abs(x)-y) .* ...
         (3*abs(x)+0.75*sqrt(abs((abs(x)-0.75).*(abs(x)-0.5))./((0.75-abs(x)).*(abs(x)-0.5)))-y) .* ...
         (2.25*sqrt(abs((x-0.5).*(x+0.5))./((0.5-x).*(0.5+x)))-y) .* ...
         (((6*sqrt(10))/7)+(1.5-0.5*abs(x)) .* sqrt(abs(abs(x)-1)./(abs(x)-1))-((6*sqrt(10))/14).*sqrt(4-(abs(x)-1).^2)-y);

imagesc( log(abs(batman)) );
"
Copy paste the code to  get awesome batman curve




2.Super Mario Brother Theme
Access this feature  using this file
"http://www.mathworks.com/matlabcentral/fileexchange/8442-theme-from-super-mario-brothers-song?download=true"
Keep these two files in the same folder and run "mariosong.m" , it Will play the ultra cool super mario music.

3.SPY
Put the "SPY" command in command window, it will create a spy image like this :-

4.TOILET COMMAND :P
Enter the "TOILET" command, it will show the simulation of toilet with flushing sound :D :P

5.The Conway's Game of Life
Yes, MATLAB  can also be used to play games,enter the Life command and play.

6.The PENNY
This gives a 3D version of a penny.
Just enter  "penny" command


7. MATLAB  PROGRESS  BAR
Copy -paste this code to get a progress bar
clc;
clear all;
tic;
disp ('Hello, World!');
h=waitbar(0,'Please wait..');
n=0;
for i=1:100
    waitbar(i/100)
    for j=1:100
        for k=0:100;
            n=factorial(2);
        end
    end
end
close(h)
toc



Reactions:

2 comments:

Related Posts Plugin for WordPress, Blogger...
Loading...