Posts Tagged ‘Functions’
Reading, Writing, and Querying Graphics Image Files
Working with Image Formats
In its native form, a graphics file format image is not stored as a MATLAB matrix, or even necessarily as a matrix. Most graphics files begin with a header containing format-specific information tags, and continue with bitmap data that can be read as a continuous stream. For this reason, you cannot use the standard MATLAB I/O commands load and save to read and write a graphics file format image. Read More
Comparing Handle and Value Classes
Why Select Handle or Value
MATLAB support two kinds of classes — handle classes and value classes. The kind of class you use depends on the desired behavior of the class instances and what features you want to use. Read More
Tags: Arrays of Handle Objects, Behavior of MATLAB Built-In Classes, Classdef, Defining Events and Listeners — Syntax and Techniques, delete, Dynamic Properties — Adding Properties to an Instance, Functions, Graphics, Handle Class Delete Methods, Handle Class Methods, How to Initialize Property Values, Implementing a Set/Get Interface for Properties, matlab, Memory Allocation for Arrays, Passing Objects to Functions, The Handle Superclass, Which Kind of Class to Use
Using the Editor and Debugger with Classes
Referring to Class Files
Define classes in M-files just like scripts and functions. To use the editor or debugger with a class file, use the full class name. For example, suppose the file for a class, myclass.m is in the following location: Read More
Modifying and Reloading Classes
Ensuring MATLAB Uses Your Changes
There is only one class definition for a given class in MATLAB at any given time. When you create an instance of a class, MATLAB loads the class definition. So as long as instances of that class exist, MATLAB does not reload the class definition. Read More
Tags: clear, Clear Classes, close, close_system, Functions, Graphics, Graphics Objects, Handle, matlab, mlock, munlock, Persistent, rmappdata, simulink, Simulink Models, variables
Finding maximum and minimum values in arrays
Let’s write a function file range.m that calculates the difference between the maximum and minimum value in a vector. The file should return a reply. Open an edit window. Create a function file like the one below. Read More
Analysis of Functions, Interpolation, Curve Fitting, Integrals and Differential Equations 2
Localize minima and maxima of functions
Let us try to find the local minima and maxima for the function func(x). The interval of interest is [-6 0]. The algorithms are iterative. There are 2 methods to use. The first one decides x in a given interval, and the second one looks for x around an initial guess. To decide the maxima we are looking for an x that minimizes the negative function: -func(x). Read More
Tags: Analysis of Functions, applications, Command Window, curve, Define, differential, end, equations, Examples, fitting, for, format, full, Functions, grid, help, hold, if, inf, info, integral, integrals, integrand, interpolation, legend, load, matlab, mesh, meshgrid, minus, plot, polynomial, rand, randn, rem, round, sign, sum, title, tutorials, ver, what
Analysis of Functions, Interpolation, Curve Fitting, Integrals and Differential Equations
In this tutorial we will deal with analysis of functions, interpolation, curve fitting, integrals and differential equations. Firstly, we will need to use polynomials and therefore we have to be familiar with the representation of these. A general polynomial looks like: p(x)=anxn + an-1xn-1 +……….+ a1x + a0 and is represented by a vector in Matlab:
p=[ an an-1 ....... a1 a0 ] Read More