background preloader

MATLAB

Facebook Twitter

Octave - Special Matrices. Go to the first, previous, next, last section, table of contents. Octave provides a number of functions for creating special matrix forms. In nearly all cases, it is best to use the built-in functions for this purpose than to try to use other tricks to achieve the same effect. Special Utility Matrices The function eye returns an identity matrix. If invoked with a single scalar argument, eye returns a square matrix with the dimension specified.

For example, eye (3) creates an identity matrix with three rows and three columns, eye (5, 8) creates an identity matrix with five rows and eight columns, and eye ([13, 21; 34, 55]) creates an identity matrix with two rows and two columns. Normally, eye expects any scalar arguments you provide to be real and non-negative.

There is an ambiguity when these functions are called with a single argument. For example, if you need to create an identity matrix with the same dimensions as another variable in your program, it is best to use code like this eye (a) GNU Octave - Matrix Factorizations. The Schur decomposition is used to compute eigenvalues of a square matrix, and has applications in the solution of algebraic Riccati equations in control. schur always returns s = u' * a * u where u is a unitary matrix (u'* u is identity) and s is upper triangular.

Are the diagonal elements of s. If the matrix a is real, then the real Schur decomposition is computed, in which the matrix u is orthogonal and s is block upper triangular with blocks of size at most 2 x 2 along the diagonal. (or the eigenvalues of the 2 x 2 blocks, when appropriate) are the eigenvalues of a and s. The eigenvalues are optionally ordered along the diagonal according to the value of opt. opt = "a" indicates that all eigenvalues with negative real parts should be moved to the leading block of s (used in are), opt = "d" indicates that all eigenvalues with magnitude less than one should be moved to the leading block of s (used in dare), and opt = "u", the default, indicates that no ordering of eigenvalues should occur. Octave Examples for Solving Linear Algebra Equations. MATLAB Graphics. MATLAB graphics can help you see the big picture in your data. It's easy to plot functions or scattered data, to sketch geometric models, to draw contour maps or 3D "mountain" plots, and to make animations.

We will quickly introduce some of the MATLAB graphics commands that will be most useful in scientific computing. Simple XY graphics We assume that the quantity Y is a function of X, or is related to X in some way. We wish to display a plot that indicates this relationship. If we have an explicit formula, Y = F(X), the appropriate command is FPLOT, as in this example: fplot ( 'x .* sin(x)', [ 0, 10*pi ] ) The formula must be enclosed in single quotes, and the variable is always called X. Figure 1: A Graph Created by FPLOT. MATLAB Syntax: Notice that in the above formula we use "*" to compute 10 * pi, but ". *" to indicate that we want to multiply X by SIN(X). A second way to carry out an X, Y plot occurs if we have a large set of data pairs (X(1),Y(1)), ..., (X(N),Y(N)).

Or 9 x2 + 16 y2 = 144. SC - powerful image rendering. SC is a useful function for displaying rich image data, of use to anyone wishing to visualize and save 2D data in ways beyond that which MATLAB built-in functions allow. This function can be used in place of IMAGE, IMAGESC and IMSHOW, but does so much more. It is fast and displays images as they should be - correct aspect ratio, integer magnification, no axes. In addition, it can return the image as an output variable - useful for saving to disk, texture mapping surfaces, and post-rendering manipulation such as overlaying/combining two or more images. All the MATLAB built-in colormaps are implemented, but without MATLAB's nasty discretization artifacts. Plus, there are many new colormaps which are helpful for viewing more complex data, such as optic flow, likelihoods over images, difference images, segmentations, stereo image pairs (as anaglyphs) and edge-maps with orientation.

It also accepts user defined linear and non-linear colormaps. How to Customize and Improve MATLAB Figures for Publication. In this post I will be showing how to produce a publication quality figure using MATLAB (2007a). To fully appreciate the content presented here you will need some working knowledge of MATLAB, meaning that you should know how to create a basic plot. If you need some help in this department you can reference this Guide from MathWorks. But, if you’re ready to create a publication quality figure (i.e., one that doesn’t look like it was made in Excel), then keep reading.

Suppose I am raising two different species of fruit flies in my lab, and once a day for 10 days I measure the size of both populations and record the numbers in two vectors called Species1 and Species2. Now I want to visually compare the growth of the two populations over the 10 days so I use the following basic plotting commands h1 = plot( Days, Species1 ); hold on; h2 = plot( Days, Species2 ); *Note that the vector ‘Days’ contains the numbers 1 through 10 which represents the days over which the experiment took place. How do I start or stop the MathWorks FLEXnet license manager?

Solution: The license manager can be started or stopped using the following methods: For Windows license manager installlations: ========== Option 1: Using LMTOOLS.exe: To use the LMTOOLS Utility (lmtools.exe) to start the license manager, follow this procedure: 1. 2. 3. 4. Option 2: Using Windows services: While LMTOOLS is the recommended method, it is also possible to start and stop the license manager using the Windows services applet. 1. 2. 3. Option 3: Start the license manager as an application: It is also possible to start the license manager using the DOS (command) prompt. 1.

For example: cd "C:\Program Files\MATLAB\R2010b\etc\win32" 3. NOTE: To stop the license manager when started in this method, you will need to kill the lmgrd.exe process that is started through Windows Task Manager. For Unix/Linux/Mac OS X license manager installations ========== For Unix/Linux/Mac OS X, the license manager is started and stopped through the terminal. Option 1: Non-boot script method 1. Write image to graphics file - MATLAB. Write image to graphics file Syntax Description example imwrite(A,filename) writes image data A to the file specified by filename, inferring the file format from the extension. imwrite creates the new file in your current folder.

The bit depth of the output image depends on the data type of A and the file format. If A is of data type uint8, then imwrite outputs 8-bit values.If A is of data type uint16 and the output file format supports 16-bit data (JPEG, PNG, and TIFF), then imwrite outputs 16-bit values. If A contains indexed image data, you should additionally specify the map input argument. example imwrite(A,map,filename) writes the indexed image in A and its associated colormap, map, to the file specified by filename. If A is an indexed image of data type double or single, then imwrite converts the indices to zero-based indices by subtracting 1 from each element, and then writes the data as uint8.

Example example Examples Resize and Save Image Write the resized image data, B, to a file. Creating Movies in MATLAB. Carl Scarrott This set of instructions detail how to create movies in MATLAB 5.1, convert them to the standard movie format MPEG and how to play them. Limited knowledge of MATLAB or the MPEG format is assumed. This code has not been verified for any other MATLAB version. How to create MATLAB movies 1) Open MATLAB figure window: >> fig1=figure(1); 2) Resize the figure window to size of movie required. 3) Record the size of the plot window: >> winsize = get(fig1,'Position'); 4) Adjust size of this window to include the whole figure window (if you require the axes, title and axis labels in the movie): >> winsize(1:2) = [0 0]; 5) Set the number of frames: >> numframes=16; 6) Create the MATLAB movie matrix: >> A=moviein(numframes,fig1,winsize); 7) Fix the features of the plot window (ensures each frame of the movie is the same size): >> set(fig1,'NextPlot','replacechildren') 8) Within a loop, plot each picture and save to MATLAB movie matrix: >> movie(fig1,A,30,3,winsize) >> save filename.mat A or in MATLAB:

MATLAB GUI Tutorial - For Beginners | blinkdagger. Why use a GUI in MATLAB? The main reason GUIs are used is because it makes things simple for the end-users of the program. If GUIs were not used, people would have to work from the command line interface, which can be extremely difficult and fustrating. Imagine if you had to input text commands to operate your web browser (yes, your web browser is a GUI too!). It wouldn’t be very practical would it? In this tutorial, we will create a simple GUI that will add together two numbers, displaying the answer in a designated text field. This tutorial is written for those with little or no experience creating a MATLAB GUI (Graphical User Interface).

Contents Initializing GUIDE (GUI Creator) First, open up MATLAB. You should see the following screen appear. You should now see the following screen (or something similar depending on what version of MATLAB you are using and what the predesignated settings are): Creating the Visual Aspect of the GUI: Part 1 Two Edit Text components. How to parse a string? (Simple question) - comp.soft-sys.matlab.