BogoToBogo
  • Home
  • About
  • Big Data
  • Machine Learning
  • AngularJS
  • Python
  • C++
  • go
  • DevOps
  • Kubernetes
  • Algorithms
  • More...
    • Qt 5
    • Linux
    • FFmpeg
    • Matlab
    • Django 1.8
    • Ruby On Rails
    • HTML5 & CSS

Matlab Tutorial - M Files (Scripts)

Matlab_logo.png




Bookmark and Share





bogotobogo.com site search:




M-Files

M-files are macros of MATLAB commands. The M-files are stored as ordinary text files with the extension m, filename.m. An M-file can be either a function with input and output variables or a list of commands.



bogotobogo.com site search:


Where?

Where should we put the M-files?

MATLAB requires that the M-file must be stored either in the working directory or in a directory that is specified in the MATLAB path list.

On Windows, the default location is C:\Documents and Settings\user\My Documents\MATLAB. We can check it by New->Script and then Save As:


M_Files_SaveAs.png

Directory.png


Specifying M-files directory

Suppose we want to have the M-files in C:\Documents and Settings\user\My Documents\MATLAB\FFT. We can let Matlab know where it can find the file in two ways:

  1. Change the working directory by issuing cd path command:
    >> pwd
    ans =
    C:\Documents and Settings\admin\My Documents\MATLAB
    >> cd FFT
    >> pwd
    ans =
    C:\Documents and Settings\admin\My Documents\MATLAB\FFT
    
  2. Add the directory to the path.
    1. Permanent addition to the path : edit the ....\MATLAB\matlabrc.m file
    2. Temporary modification to the path : issue a command, path(path,'C:\Documents and Settings\user\My Documents\MATLAB\FFT') withing Matlab



A function defined in M-File

In this section, we'll see how the M-files are used.

Let's create a file in our working directory (the default directory mentioned in previous section). Name it as cexp.m that has the following commands:

function fval = cexp(a,b)
fval = exp(a+b*i)

Then within the command window:

>> x = 1;
>> y = 2;
>> cexp(x,y)
fval =
  -1.1312 + 2.4717i
ans =
  -1.1312 + 2.4717i
>> 








Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization

YouTubeMy YouTube channel

Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong







Matlab Image and Video Processing



Vectors and Matrices

m-Files (Scripts)

For loop

Indexing and masking

Vectors and arrays with audio files

Manipulating Audio I

Manipulating Audio II

Introduction to FFT & DFT

Discrete Fourier Transform (DFT)



Digital Image Processing 2 - RGB image & indexed image

Digital Image Processing 3 - Grayscale image I

Digital Image Processing 4 - Grayscale image II (image data type and bit-plane)

Digital Image Processing 5 - Histogram equalization

Digital Image Processing 6 - Image Filter (Low pass filters)

Video Processing 1 - Object detection (tagging cars) by thresholding color

Video Processing 2 - Face Detection and CAMShift Tracking




Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong







OpenCV 3 -

image & video processing



Installing on Ubuntu 13

Mat(rix) object (Image Container)

Creating Mat objects

The core : Image - load, convert, and save

Smoothing Filters A - Average, Gaussian

Smoothing Filters B - Median, Bilateral






OpenCV 3 image and video processing with Python



OpenCV 3 with Python

Image - OpenCV BGR : Matplotlib RGB

Basic image operations - pixel access

iPython - Signal Processing with NumPy

Signal Processing with NumPy I - FFT and DFT for sine, square waves, unitpulse, and random signal

Signal Processing with NumPy II - Image Fourier Transform : FFT & DFT

Inverse Fourier Transform of an Image with low pass filter: cv2.idft()

Image Histogram

Video Capture and Switching colorspaces - RGB / HSV

Adaptive Thresholding - Otsu's clustering-based image thresholding

Edge Detection - Sobel and Laplacian Kernels

Canny Edge Detection

Hough Transform - Circles

Watershed Algorithm : Marker-based Segmentation I

Watershed Algorithm : Marker-based Segmentation II

Image noise reduction : Non-local Means denoising algorithm

Image object detection : Face detection using Haar Cascade Classifiers

Image segmentation - Foreground extraction Grabcut algorithm based on graph cuts

Image Reconstruction - Inpainting (Interpolation) - Fast Marching Methods

Video : Mean shift object tracking

Machine Learning : Clustering - K-Means clustering I

Machine Learning : Clustering - K-Means clustering II

Machine Learning : Classification - k-nearest neighbors (k-NN) algorithm










Contact

BogoToBogo
contactus@bogotobogo.com

Follow Bogotobogo

About Us

contactus@bogotobogo.com

YouTubeMy YouTube channel
Pacific Ave, San Francisco, CA 94115

Pacific Ave, San Francisco, CA 94115

Copyright © 2024, bogotobogo
Design: Web Master