Search This Blog

MATLAB Tricks with code

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

2. The PENNY
This gives a 3D version of a penny.
Just enter  "penny" command
Copy -paste this code to get a progress bar

4. Why Command 
you will get "Stupid Question!"

5. SURF Command
try surf(membrane) to get the below image. 

6. "earthmap" command:
This command will show up the earth map, that is also rotatable. (Just use the hand tool from the toolbox). This example shows several ways to represent the Earth's topography.

  Name            Size              Bytes  Class     Attributes

  topo          180x360            518400  double              
  topomap1       64x3                1536  double 

7. x=[-2:.001:2],y=(sqrt(cos(x)).*cos(200*x)+sqrt(abs(x))-0.7).*(4-x.*x).^0.01,plot(x,y);

Just copy and paste above command, & you will see that a "heart shaped" waveform is plotted.

8. "life" command:

MATLAB's version of Conway's Game of Life. "Life" is a cellular automaton invented by John Conway that involves living and dead cells in a rectangular, two-dimensional universe. In MATLAB, the universe is a sparse matrix that is initially all zero.

Whether cells stay alive, die, or generate new cells depends upon how many of their eight possible neighbors are alive. By using sparse matrices, the calculations required become astonishingly simple. We use periodic (torus) boundary conditions at the edges of the universe. Pressing the "Start" button automatically seeds this universe with several small random communities. Some will succeed and some will fail.

  "cruller" command:

This command will fetch you a 3-D shape, that is rotatable ( Just use the hand tool ).
This example shows how to construct a cruller by revolving the eccentric ellipse defined by the function XYCRULL. 

10. "xpsound" command:

Demonstrate MATLAB's sound capability.

You may view the audio graphically in three ways:

# The time sequence is a 2D plot of the data as a function of time.

# In the PSD form.

# In the spectrogram view. 

11. "xpbombs" command:

Play the minesweeper game in MATLAB's style. There are 13 bombs hidden in the mine field. Try to flag them and uncover all of the other spaces without getting blown up. In each non-bomb square is printed the number of adjacent squares which contain bombs. In our case we lost, try to win!

"image" command:

We might have used many image related commands, like imread, imshow etc. But have you tried "image" command? Yes, just type in image in the command window of MATLAB without any parameter, & you will see an inverted child's image. 

Join us on Telegram:

No comments