MATLAB was originally developed to be a "matrix laboratory," written to provide easy access to matrix software developed by the LINPACK and EISPACK projects. Since then, the software has evolved into an interactive system and programming language for general scientific and technical computation and visualization. The basic MATLAB data element is a matrix. MATLAB commands are expressed in a form very similar to that used in mathematics and engineering. For instance, b = A x, where A, b, and x are matrices, is written b = A * x . To solve for x in terms of A and b, write x = A\b .
There is no need to program matrix operations explicitly like multiplication or inversion. Solving problems in MATLAB is, therefore, generally much quicker than programming in a high-level language such as C or FORTRAN. There are hundreds of built-in functions that come with the basic MATLAB and there are optional "toolboxes" of functions for specific purposes such as Controls, Signal Processing, and Optimization. Most of the functions in MATLAB and the Toolboxes are written in the MATLAB language and the source code is readable. There are two basic versions of the software, the professional version, and the student edition. The student edition is distributed by Prentice-Hall, the professional version is distributed by The MathWorks, Inc. Send an email to info@mathworks.com or call 508-65-pi (508-653-1415) for more information.
SIMULINK is an interactive system for the nonlinear simulation of dynamic systems. It is a graphical, mouse-driven program that allows systems to be modeled by drawing a block diagram on the screen. It can handle linear, nonlinear, continuous-time, discrete-time, multivariable, and multirate systems. SIMULINK runs on workstations using X-Windows, under Microsoft Windows on the PC, and on the Macintosh. It takes full advantage of windowing technology, including pull-down windows and mouse interactions. SIMULINK is fully integrated with MATLAB, and, together with MATLAB and the Control System Toolbox, forms a complete control system design and analysis environment.
MATLAB is available on machines ranging from the PC to the Cray. The list includes PC, Macintosh, and NEC personal computers, Sun, DEC, HP, IBM, and SGI workstations, VAX minicomputers, and Convex and Cray supercomputers.
MATLAB was first. The MathWorks, Inc. was founded in 1984 to develop and market MATLAB.
In the mid-1970s, Cleve Moler and several colleagues developed the FORTRAN subroutine libraries called LINPACK and EISPACK under a grant from the National Science Foundation. LINPACK is a collection of FORTRAN subroutines for solving linear equations, while EISPACK contains subroutines for solving eigenvalue problems. Together, LINPACK and EISPACK represent the state of the art software for matrix computation. In the late 1970s, Cleve, who was then chairman of the computer science department at the University of New Mexico, wanted to be able to teach students in his linear algebra courses using the LINPACK and EISPACK software. However, he didn't want them to have to program in FORTRAN, because this wasn't the purpose of the course. So, as a "hobby" on his own time, he started to write a program that would provide simple interactive access to LINPACK and EISPACK. He named his program MATLAB, for MATrix LABoratory. Over the next several years, when Cleve would visit another university to give a talk, or as a visiting professor, he would end up by leaving a copy of his MATLAB on the university machines. Within a year or two, MATLAB started to catch on by word of mouth within the applied math community as a "cult" phenomena.
The newsgroup comp.soft-sys.matlab is a forum for discussing issues related to the use of MATLAB, the scientific calculation and visualization package from The MathWorks Inc.
Appropriate discussion in the group will include both general MATLAB issues and platform-specific questions, and discussions comparing MATLAB to other systems.
The MathWorks maintains an archive on the anonymous ftp server ftp.mathworks.com [144.212.100.10]. This site contains a "best of" copy of the NETLIB archive as well as other user-contributed, and MathWorks-contributed software and documentation. If you are interested in submitting software to the archive, get the file /README.incoming on the ftp site or send email to: drea@mathworks.com.
Yes, The MathWorks Inc. publishes a quarterly newsletter that gives information on products (new versions, releases, toolboxes), the MATLAB user group, MATLAB short courses, related texts etc. There is also a monthly email digest that contains annoncements, Q &A requests from users, news about our Internet services, etc. To subscribe to the newsletter, send email to subscribe@mathworks.com (Be sure to include your address adn your site identification/license number. To find out your site id, type "ver" at the MATLAB prompt.), or just type subscribe at your MATLAB prompt.
Control System Toolbox : This is a toolbox for control system design and analysis. It supports transfer function and state-space forms (continuous/discrete time, frequency domain), as well as functions for step, impulse, and arbitrary input responses. Functions for Bode, Nyquist, Nichols plots, design with root-locus, pole-placement, and LQR optimal control are also included.
Image Processing Toolbox : The Image Processing Toolbox builds on MATLAB's numeric, signal processing, and visualization capabilities to provide a comprehensive system for image processing and algorithm development.
MMLE3 Identification Toolbox : The MMLE3 Identification Toolbox is a specialized toolbox for use with MATLAB and the Control System Toolbox for the estimation of continuous-time state-space models from observed input-output data.
Model Predictive Control Toolbox : The Model Predictive Control Toolbox is especially useful for applications involving constraints on the manipulated and/or controlled variables. For unconstrained problems, model predictive control is closely related to linear quadratic optimal control, but includes modeling and tuning options that simplify the design procedure.
Mu-Analysis and Synthesis Toolbox : The Mu-Analysis and Synthesis Toolbox contains specialized tools for the analysis and design of robust, linear control systems, extending MATLAB to provide additional application-specific capabilities.
Nonlinear Control Design : This toolbox provides a Graphical User Interface to assist in time-domain-based control design. With this toolbox, you can tune parameters within a nonlinear SIMULINK model to meet time-domain performance requirements. You can view the progress of an optimization while it is running. Optimization routines have been taken from the Optimization Toolbox.
Neural Network Toolbox : This is a toolbox for designing and simulating neural networks and supports implementation of the perceptron learning rule, the Widrow-Hoff rule, and several variations of the backpropagation rule. Transfer functions included are hard limit, linear, logistic, and hypertangent sigmoid.
Optimization Toolbox : This is a toolbox for linear and nonlinear optimization. It supports unconstrained and constrained minimization, minimax, nonlinear least squares, multi-objective, semi-infinite optimization, linear programming, quadratic programming, and the solution of nonlinear equations.
Robust Control Toolbox : This is a toolbox for robust control system design and supports LQG/loop transfer recovery, H2, H0, and mu- control synthesis, singular value frequency response, and model reduction.
Signal Processing Toolbox : This is a toolbox for digital signal processing (time series analysis). It includes functions for the design and analysis of digital filters, like Butterworth, Elliptic, and Parks-McClellan, and for FFT analysis (power spectrum estimation). It also includes some two-dimensional signal processing capabilities.
Spline Toolbox : This is a toolbox for working with splines and is typically used for curve fitting, solution of function equations, and functional approximation.
Statistics Toolbox : The Statistics Toolbox builds on the computational and graphics capabilities of MATLAB to provide: 1) statistical data analysis, modeling, and Monte Carlo simulation 2) building blocks for creating your own special-purpose statistical tools, and 3) GUI tools for exploring fundamental concepts in statistics and probability.
Symbolic Math Toolbox : The Symbolic Math Toolbox contains functions for symbolic algebra, exact linear algebra, variable precision arithmetic, equation solving, and special mathematical functions. Its underlying computational engine is the kernel of Maple. The Extended Symbolic Math Toolbox augments the functionality to include Maple programming features and specialized libraries.
System Identification Toolbox : This is a toolbox for parametric modeling. Identified models are in transfer function form (either z transform or Laplace transform) and state-space form (e.g., ARMA models or Box-Jenkins models).
Chemometrics Toolbox : This toolbox contains a library of functions that allows you to analyze data based on chemometrics methods including multiple linear regression, classical least squares, inverse least squares, Q-matrix, factor based methods, principle component regression, and partial least squares in latent variables. There are also useful functions for plotting data.
Frequency Domain System Identification Toolbox : This toolbox contains specialized tools for identifying linear dynamic systems from measurements of the system's excitation and response. Some of the identification procedures include excitation signal design, parameter estimation, graphical presentation of results, and model verification.
Hi-Spec [tm] Toolbox : The Hi-Spec [tm ] Toolbox, a Partner Series Toolbox, was created by Jerry Mendel, C.L. (Max) Nikias, and Ananthram Swami. The Hi-Spec Toolbox is a collection of MATLAB routines whose primary features are functions for:
Toolkits are also available from The Mathworks, Inc. Toolkits are colections of M-files associated with books. These are available from the publisher or from ftp.mathworks.com in /pub/books .
Control of Spacecraft and Aircraft Toolkit : This is a package of MATLAB programs to demonstrate the concepts discussed in the text "Control of Spacecraft and Aircraft," by Arthur E. Bryson. (1994) Princeton University Press, 1994.
Signal Processing Examples Toolkit : This is a package of MATLAB programs to demonstrate the concepts discussed in the text "Computer-Based Exercises for Signal Processing Using MATLAB," by C. Sidney Burrus, James H. McClellan, Alan V. Oppenheim, Thomas W. Parks, Ronald W. Schafe, and Hans Schuessler. (1994) Prentice Hall.
Delta Toolkit : This is a toolkit for analysis using the delta transform, an approach to unifying continuous and discrete systems theory without use of the z transform. It is available free to purchasers of "Digital Control and Estimation: A Unified Approach," by Graham Goodwin and Rick Middleton.
Numerical Methods for Physics Toolkit : This is a toolkit for which demonstrates the concepts discussed in the text "Numerical Methods for Physics Using MATLAB," by Alejandro Garcia. (1994) Prentice Hall. It is available free to purchasers of this text.
Numerical Methods for Mathematics, Science and Engineering Toolkit : This is a toolkit for which demonstrates the concepts discussed in the text "Numerical Methods for Mathematics, Science and Engineering, Second Edition," by John H. Matthews. (1994) Prentice Hall. It is available free to purchasers of this text.
Introduction to Linear Algebra Toolkit : This is a package of MATLAB programs to use with MATLAB in learning and experimenting with linear algebra. The toolbox is coordinated with the text: "Introduction to Linear Algebra," by Gilbert Strang. (1993) Wellesley-Cambridge Press Box 812060 Wellesley MA 02181.
Templates Toolkit. The M-files were created to supplement "Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods," by Richard Barrett, Michael Berry, Tony Chan, James Demmel, June Donato, Jack Dongarra, Victor Eijkhout, Roldan Pozo, Charles Romine, and Henk van der Vorst (SIAM, 1994).
* support@mathworks.com Technical support
* suggest@mathworks.com Product enhancement suggestions
* bugs@mathworks.com Bug reports
* doc@mathworks.com Documentation error reports
* subscribe@mathworks.com Subscribing user registration
* service@mathworks.com Order status, renewals, passcodes
* info@mathworks.com Sales, pricing, general info.
* digest@mathworks.com Submission and questions for the digest
* Ability to produce hpgl format files
* Ability to import graphs into Adobe Illustrator '88
* Ability to save a figure and load it back into MATLAB
* Better, faster graphics
* DDE capability for the PC
* Online documentation for UNIX systems
* International Character Support (limited)
* Many memory leak fixes
The PC, SunOS, Solaris 2.2 and 2.3 and HP700 versions were released in late April 1994. Other UNIX platforms and the VMS version will follow shortly. In late May, the Mac version came out. The version for Power PC for the Mac will be released in late 1994.
One way to measure the speed of MATLAB is by looking at the LINPACK benchmarks:
One way to measure the speed of MATLAB is by looking at the LINPACK benchmarks:
PC performance range: LINPACK (KFLOPS)
VAXstation 3100 (VMS/D_floating) 365
HP 9000/400 (68030) 500
80486-based PC (33M Hz) 1300
HP 9000/425 (68040 chip) 1400
Macintosh Quadra 700 1500
Sun SPARCstation 1 1500
DECstation 3100 1600
SGI Indigo 2400
Sun SPARCstation 2 3600
Sun SPARCstation 10 9500
Convex C1 3700
IBM RS/6000 7000
HP 9000/700 7400
Cray X-MP 71000
Cray X-MP on a 500-by-500 matrix 135000
SIMULINK has added the following features in version 1.3:
* Vectorization of blocks
* Scalar expansion of inputs
* Automatic routing of block connections
* Wide vector lines
* Sample time coloration of model
* Enhanced S-functions
* Many bew blocks!
The second way to call MATLAB routines from your program is to use MATLAB as a computational engine. A set of subroutines is provided that allows you to start MATLAB, send data and commands to it, get data back, and terminate MATLAB. This way you can call any MATLAB routine from your FORTRAN or C function.
Removing the last line %%EOF from the eps-file.
Use the pstoepsi filter from Doug Crabill ( dgc@cs.purdue.edu ).
Use bbps and GhostScript. bbps.shar is available via anonymous ftp on csi.jpl.nasa.gov . You'll need to get GhostScript from your nearest GNU ftp site.
Also, there is a technical note written on this topic available on our anonymous ftp server. It can be found in pub/tech-support/tech-notes/mat4.txt .
Try the following:
set OLDDISPLAY=$DISPLAY
unsetenv DISPLAY
nohup matlab < filein > fileout &
setenv DISPLAY $OLDDISPLAY
where filein is the M-file you want to run and fileout is the file you want the output to go to. To set this up as a C shell script, write a file called matbat as:
#!/bin/csh set OLDDISPLAY=$DISPLAY
unsetenv DISPLAY nohup matlab < $1 > $2 &
setenv DISPLAY $OLDDISPLAY
To run this file, issue the command as:
matbat infile outfile
In MS Windows: You need to set the ratio for applications running in the foreground as opposed to running in the background. This ratio will determine how well you can run MATLAB in the background. To set this ratio, go into 386 Enhanced in your Windows Control Panel. You can change your ratio here.
Make sure that you don't have any other large applications running in the background and that there aren't a lot of other people logged onto your machine. These things can also cause MATLAB to run slowly.
From gray@SCR.slb.com ... If you're running MATLAB 4.x, something like the following should appear in your startup.m file:
set(0,'DefaultFigurePosition',[5,5,505,405])
set(0,'DefaultFigureColor',[0,0,0]) %%N.B this has side
%%effects.
set(0,'DefaultAxesFontName','times')
set(0,'DefaultTextFontName','times')
set(0,'DefaultAxesFontSize',12)
set(0,'DefaultTextFontSize',12)
or from Brian Fitzgerald < fitzgb@mml0.meche.rpi.edu > ...
figure(1)
set(1,'Position', [ 10 10 610 610])
When you use a function that calls a colormap, the function assigns values in the matrix to certain values in the default colormap. The lowest value in your matrix is assigned to the first color in your colormap.
There is a colormap command in MATLAB, which allows you to set your colormap to 10 different sets of colors. For example,
colormap cool
gives you shades of cyan and magenta while
colormap jet
gives you shades of blue.
You can set a limit on your colors using the functions caxis, cmin, and cmax. These functions let you define the range of colors you will be using.
Yes. The function you're looking for is lookfor (in MATLAB 4).
>> lookfor fourier
FFT Discrete Fourier transform.
FFT2 Two-dimensional Fast Fourier Transform.
IFFT Inverse discrete Fourier transform.
IFFT2 Two-dimensional inverse discrete Fourier transform.
FOURIER Graphics demo of Fourier series expansion.
DFTMTX Discrete Fourier transform matrix.
Most things in the /demos directory are not described in the MATLAB User's Guide. There are lots of goodies there. In 4.0, the demos are the best place to see examples of Handle Graphics.
There are other undocumented functions in directories other than /demos. Some of them are "worker" functions that are unlikely to be used directly; they are simply called by other functions. A few, like comet and comet3, were written after the MATLAB User's Guide was sent to the printer.
The algorithm for the rand function can be found in S. K. Park and K. W. Miller, "Random Number Generators : Good ones are hard to find," Comm. ACM, vol. 32, n. 10, Oct. 1988, pg 1192-1201. The formula used for the seed is:
seed=(7^5*seed)mod(2^31-1)
If you want to set the initial seed to an random value, type the following at the MATLAB prompt:
rand('SEED',fix(100*sum(clock)))
This will use the clock to set the seed.
There is a PRBS generating M-file in the new Frequency Domain System Identification Toolbox, for lengths 2^2-1 to 2^30-1. Its name is mlbs (for Maximum Length Binary Sequence).
In MATLAB, numeric quantities are represented as double precision floating point numbers. On most computers, such numbers have 53 significant binary bits, which is about 15 or 16 decimal digits.
Here is an example of how to run MATLAB in batch mode from your UNIX prompt:
Bourne shell example: (file called atfile.sh )
TERM=; export TERM matlab > inline.out << EOF a = [1 2] quit EOF
Sample at command on Sun: (-s says use the Bourne shell)
% at -s now + 1 min atfile.sh
C shell example: (file called atfile.csh )
setenv TERM matlab >! inline.out << EOF a = [1 2] quit EOF
Sample at command on Sun:
% setenv SHELL '/bin/csh -f' % at now + 1 min atfile.csh % setenv SHELL /bin/csh
In summary,
Define TERM in the script before you call MATLAB and make it part of the environment. Be sure that the right shell is used to execute the script. If your script is a C shell, you must do the SHELL change in order not to get any extra mail messages from the job.
Remember that -f means that your .cshrc file will not be executed before you run the script. So, you cannot use any of the parameters set in the script.
MATLAB itself has no limits on matrix or vector sizes. There are no fixed-size arrays dimensioned within the MATLAB program.
MATLAB uses the dynamic memory allocation and virtual memory facilities provided by most operating systems to obtain its memory. Any limits on memory and hence matrix size are those imposed by the operating system or the hardware. On most computers, these limits can be set arbitrarily large by the user or the system manager.
The Student Edition version is limited to variables of size 32 by 32.
MATLAB began as a FORTRAN program and we have kept the convention of beginning our indices at one instead of at zero. You also cannot have negative indices to vectors of matrices.
Many MATLAB users commonly ask the question, "Can I use multidimensional arrays in MATLAB?" The anwser is both yes and no.
No, in that multidimensional arrays are not built into MATLAB. MATLAB's internal data stucture is limited to a two-dimensional matrix. But you can create your own functions in the MATLAB language to handle multidimensional arrays. The following is an example that maps a three-dimensional matrix to a single vector. The indices are passed to a function as if it were a three-dimensional matrix. Then the indices are translated to a single vector with corresponding offsets. The exact implementation will be specific to what you want to accomplish.
%INDEX3 POSITION = INDEX3(d,i,j,k) index a 3-D array % d is a vector that specifies the dimensions on the array function position = index3(d,i,j,k) position = (i+(j-1)*d(2)+(k-1)*d(2)*d(3));
The following is an example of how you might use this function.
D = [9 9 9]; % D give the dimensions as 9x9x9 A = 1:(9*9*9); % A is where your 3D data is % stored A(index(D,5,4,4)) = 77; % Write to it B = A(index(D,5,4,4)); % Read from it
You can create N-dimensional arrays with different limits on each dimension. The main difference is that you would change how the offset is indexed through your matrix. Each additional dimension would require a corresponding offset. You can add error checking for the indices to make sure you do not go out of bounds.
Here's "Tony's trick," attributed to Tony Booer of Schlumberger:
To initialize a matrix with values "a" in the first row and values "b" in the second row, do the following:
[a(1,ones(1,m)) ; b(1,ones(1,m))]
When you write an M-file in MATLAB, you can either write a script or a function. The difference is that a script is read from the disk and parsed line by line each time it is called. A function is loaded into RAM for execution. Because it is loaded into RAM, when you edit a function, that change is not loaded into RAM until a call to the new function is made.
To get MATLAB to recognize your edited function, type
clear functions
to clear all functions, or
clear <function name>
to clear just your function out of RAM.
MATLAB parses code to look for syntax errors. When the parser encounters a name with two or less arguments, it lets them pass since they might be a variable with indices. If it encounters a name with three or more arguments, MATLAB knows it cannot be a variable, so the error message is returned. If you don't want the parser to snag the function, specify one with twp or less arguments.
A GNU emacs 'matlab-mode' is available via anonymous ftp from csi.jpl.nasa.gov as pub/matlab/util/matlab-mode.el or, ftp.mathworks.com as /pub/contrib/tools/matlab-mode.el.
Yes, MATLAB does have a debugger. To find out more, type
help debug
at the MATLAB prompt.
name = 'xyz.mat'; eval(['save ', name]); eval(['load ', name]); name = 'myfigure.ps'; eval(['print ',name]);
The algorithms used by fsolve were not numerically well behaved. MathWorks did not feel that these algorithms met the standards required for approved software. We recommend the version of fsolve in the Optimization Toolbox .
If your site doesn't have the Optimization Toolbox, you can get the old version of fsolvefrom ftp.mathworks.com in /pub/contrib/optim/fsolve35.
griddatais a function that interpolates your data to generate evenly spaced data for plotting.
Example: x,y,z => irregularly spaced data
xmin=min(x); ymin=min(y); xmax=max(x); ymax=max(y); xi=xmin:0.02*(xmax-xmin):xmax; yi=ymin:0.02*(ymax-ymin):ymax; zi=griddata(x,y,z,xi',yi); contour(xi,yi,zi)
The fft in MATLAB is defined as sum(x(i)*exp(-j*i*k/N)) and not sum(x(i)*exp(j*i*k/N)). The first version is traditionally used by engineers, the second version by mathematicians.
There are many ways to fit a curve in MATLAB. The most common is to use polyfit to fit your data to a polynomial. Here is an example of how to use polyfit to fit data:
x = 1:10; y = exp(x); % create exponential data to be fitted c = polyfit(x,y,9); % generate coefficients for a fitted % polynomial of degree 9 yfit = polyval(c,x); % evaluate the polynomial at x plot(x,y,'yo',x,yfit,'r-') % plot the results
There is a technical note on fitting a function to data using leastsq which can be found on the ftp server under pub/tech-support/tech-notes/math4.txt.
To find out more, take a look at the online help available for these functions. Also, there is a technical note describing how to load and save data in MATLAB which can be found on the ftp server under pub/tech-support/tech-notes/io1.txt.
quad uses an adaptive recursive Simpson's rule, quad8 uses an adaptive recursive Newton Cotes 8 panel rule, and ode23 uses the Runge-Kutta method. In addition to ode23 , there is an ode45 function, which uses a 4th and 5th order Runge-Kutta as opposed to ode23 's 2nd and 3rd order.
ode23 and ode45 are called as follows:
= ode45('yprime', T0, Tfinal, Y0)
where the inputs to the function are:
F - String containing name of user-supplied problem description.
Call: yprime = fun(t,y) where F = 'fun' .
t - Time (scalar).
y - Solution column-vector.
yprime - Returned derivative column-vector; yprime(i) = dy(i)/dt.
t0 - Initial value of t.
tfinal- Final value of t.
y0 - Initial value column-vector.
tol - The desired accuracy. (Default: tol = 1.e-6 ).
trace - If nonzero, each step is printed. (Default: trace = 0 ).
The call to quad and quad8 is as follows:
Q = quad8(F,A,B,TOL,TRACE)
However, if you want to pass extra parameters to the function, do as follows:
Q = quad8('F',A,B,TOL,TRACE,P1,P2,...)
This allows coefficients P1, P2, ... to be passed directly to function F:
function g=f(a,b)
G = F(X,P1,P2,...).
To use default values for tol or trace , you can pass in the empty matrix.
For more information, take a look at the technical note on this topic. It can be found on the ftp site in pub/tech-support/tech-notes/math1.txt.
Here are some additional system specific tips:
MS-Windows: Increase the swap space by opening the Control Panel, double-clicking on the 386 Enhanced icon, and pressing the Virtual Memory button.
Macintosh: Under Multi-Finder, change the application memory size by using Get Info on the program icon. Under Single-Finder, install more memory.
VAX/VMS: Ask your system manager to increase your working set.
UNIX: Ask your system manager to increase your swap space.
OPTION 1: Edit the matlab.bat file, add the following line above the pcmatlab line, set N087=1 , so it will look like this:
set NO87=1 (there are no spaces on either side of the =, and that is a letter O not the number 0.)
pcmatlab .....
OPTION 2:
Go to the MATLAB bin directory (cd matlab/bin)
Copy PCMATLAB.EXE to PACMATLAB.ORG.
Rename PCMATLAB.EXE to PCMATLAB.DAT (using the DOS ren command)
At the DOS prompt, type debug pcmatlab.dat and press enter. You will be at the left margin with a minus sign.
At the minus, type rcs and it will return CS xyyy where x and y are numbers. You will then be at the colon prompt.
At the colon prompt, hit return and you'll get back the minus prompt.
At the minus prompt, enter e zyyy:11 where z=x+3, then press return. You should get back zyyy:0011 25 .
Immediately following zyyy:0011 25 . type D followed by a space. This should return 3C. on the same line.
Immediately following 3C. type 3F followed by a space. This should return FF. on the same line.
Immediately following FF. , type 0 (zero) and press return. You will be back at the minus prompt.
Enter w and press return. The text Writing 51F92 bytes will be displayed and you will be back at the minus prompt.
Enter q and press return. You will be back at the DOS prompt.
Rename PCMATLAB.DAT to PCMATLAB.EXE (using the DOS ren command).
A handle is a number assigned by MATLAB to a graphics object. For example, you can have a handle to each object in a plot that contains many objects such as lines, patches, and surfaces. Once you know the handle to an object, you can alter its properties. To find out what properties are associated with each object, see axis , figure , line , patch , surf , root , and image .
If you wanted to get the handle to a line when you plot it, you would do the following:
handle=plot(x,y)
You can either get or set a property of an object in the following manner:
get(handle,'PropertyName')
set(handle,'PropertyName','PropertyValue')
Two common handles are gca and gcf which stand for 'get current axes' and 'get current figure', respectively. If you use gca or gcf as the handle in your get or set statement, you will be able to change the properties of the current figure or current axes without previously defining their handles.
For more information, look at the MATLAB technical note written on this topic. It can be found on the ftp site in pub/tech-support/tech-notes/gr12.txt.
set(handle)
This returns a list of all the properties associated with that object as well as each property's optional settings. The settings in { } are the default settings.
h=get(object's_handle,'Parent')
To set the default, type the following:
set(h,'DefaultObjectPropertyName','PropertyValue')
Don't put any spaces in the DefaultObjectPropertyName expression. A good example of how to do this is the following:
set(gca,'DefaultLineLineWidth',10)
Any line you plot after this statement will have a line width of 10.
set(gca,'DefaultLineLineWidth','factory')
How do I change the font of labels?
When you change the default font name and font size, the factory settings will still be used when drawing the title and lables on the screen. Following is a modified xlabel, ylabel, zlabel, and title to recognize changes to the default FontName and FontSize; however, it would be just as easy to have it recognize changes to all the default text font properties. Below are the revised programs:
<------- XLABEL.M ------->
function xlabel(string)
% XLABEL X-axis labels for 2-D and 3-D plots.
% XLABEL('text') adds text below the X-axis on the current % axis.
%
% See also YLABEL, ZLABEL, TITLE, TEXT.
% Copyright (c) 1984-92 by The MathWorks, Inc.
h = get(gca,'xlabel');
ht = get(text,'fontname');
hs = get(text,'fontsize');
if isempty(h)
h = text('HorizontalAlignment','center');
set(gca,'xlabel',h);
end
set(h,'string',string,'fontname',ht,'fontsize',hs);
<------- YLABEL.M ------->
function ylabel(string)
% YLABEL Y-axis labels for 2-D and 3-D plots.
% YLABEL('text') adds text beside the Y-axis on the current % axis.
%
% See also XLABEL, ZLABEL, TITLE, TEXT.
% Copyright (c) 1984-92 by The MathWorks, Inc.
h = get(gca,'ylabel');
ht = get(text,'fontname');
hs = get(text,'fontsize');
if isempty(h)
h = text;
set(gca,'ylabel',h);
end
set(h,'string',string,'fontname',ht,'fontsize',hs);
<------- ZLABEL.M ------->
function zlabel(string)
% ZLABEL Z-axis labels for 3-D plots.
% ZLABEL('text') adds text above the Z-axis on the current % axis.
%
% See also XLABEL, YLABEL, TITLE, TEXT.
% Copyright (c) 1984-92 by The MathWorks, Inc.
h = get(gca,'zlabel');
ht = get(text,'fontname');
hs = get(text,'fontsize');
if isempty(h)
h = text;
set(gca,'zlabel',h);
end
set(h,'string',string,'fontname',ht,'fontsize',hs);
<------- TITLE.M ------->
function title(string)
% TITLE Titles for 2-D and 3-D plots.
% TITLE('text') adds text at the top of the current axis.
%
% See also XLABEL, YLABEL, ZLABEL, TEXT.
% Copyright (c) 1984-92 by The MathWorks, Inc.
h = get(gca,'title');
ht = get(text,'fontname');
hs = get(text,'fontsize');
if isempty(h)
h = text('horiz','center');
set(gca,'title',h);
end
set(h,'string',string,'fontname',ht,'fontsize',hs);
For more information, see the MATLAB technical note written on this topic. It is located on the ftp site in pub/tech-support/tech-notes/gr2.txt.
To change the font name or font size of a text object, do the following
set(h,'FontName','font')
where his the handle to the text object, and font is the name of the font you wish to use.
For more information, see the MATLAB technical note written on this topic. It is located on the ftp site in pub/tech-support/tech-notes/gr6.txt.
set(gca,'FontStyle','courier')
will change the font of x and y tick labels before they are created. To change the font of existing labels, do the following:
h=get(gca,'Xlabel'); set(h,'FontName',font);
For more information, see the MATLAB technical note written on this topic. It is located on the ftp site in pub/tech-support/tech-notes/gr10.txt.
You can obtain Greek characters from the symbol font. To implement:
h=text(x,y,'string') set(h,'FontName','courier');
or
set(gca,'FontName','symbol'); text(x,y,setstr(num));
where x and yare the coordinates on the graph where you want to place the Greek symbols, and num is the value from the list of 0-255 characters from the symbol font. To display a table of the symbol font, you can use the following M-file called chart.m.
function chart( fontname )
% CHART Show ANSI-chart like display of characters MATLAB
%can produce.
% CHART( 'fontname' ) will put up a figure
% window with all 255
% characters of the named font in a 16x16 grid.
% Close figure when done, it creates 256 text
% objects. You may want
% that memory back!
% Chuck Packard, The Mathworks, Inc., 25 Jan 93
% This is an unsupported, purely for example, M-
% file.
%
%
% TO USE THIS CHART:
% USE SETSTR( VALUE), WHERE VALUE=( (16*XCOORD)+YCOORD)
%
%
% make a new figure and axis
% (I'm assuming you want to keep the current graph in the
% gcf.)
%
figure;
axis([-1 16 -1 16])
ax = gca;
%
%set font to be used
%
set(ax, 'DefaultTextFontName', fontname )
%
%some other Handle Graphics settings, written out in
%full.
%See manual for more info.
%
set(ax, 'YDir', 'Reverse', 'Box', 'on')
set(ax, 'YTick', 0:15, 'XTick', 0:15)
set(ax, 'DefaultTextHorizontalAlignment', 'Center')
set(ax, 'DefaultTextVerticalAlignment', 'Bottom')
%
%not vectorized like all 'good' MATLAB M-files, but
%easier to understand!
%
x = reshape( 0:255, 16, 16 );
for h=1:16
for v=1:16
text(h-1,v-1,setstr(x(v,h)));
end
end
No, you cannot mix fonts, font styles, or font sizes within a text object.
To change the line width, do the following:
set(h,'LineWidth',size)
where h is the handle to a line and size is the width you want. The default line width is 0.5.
The following is an M-file that allows you to cycle through the line styles in the order you want when you print:
function prtlines(a1,a2,a3,a4,a5)
% PRTLINES is a front-end to PRINT which converts
% solid lines to various line styles for graphical
% output. The change is transparent to the user.
% Non-solid lines are not affected.
%
% PRTLINES is used in the same manner as PRINT.
%
% The default line styles are:
%
%'. '
%'o '
%'x '
%'+ '
%'- '
%'* '
%': '
%'-.'
%'--'
%
% The line style can be changed by editing the file
% and changing the 'styles' array.
%
% SEE ALSO: PRINT, Properties of LINE
% Written by John L. Galenski III
% All Rights Reserved 10/14/93
% LDM101493jlg
%% PRTLINES is an M-file developed by me for my own
%% personal use, and therefore, it is not supported
%% by The MathWorks, Inc., or myself. Please direct
%% any questions or comments to johng@mathworks.com.
% Create the array of line styles.
styles = [
'. '
'o '
'x '
'+ '
'- '
'* '
': '
'-.'
'--'
];
% Get the Children of the Figure.
a = get(gcf,'children');
% Check the Children of 'a'. If they are
% solid lines, then change their LineStyle
% property.
for j = 1:length(a)
l = sort(get(a(j),'children'));
X = 0;
Add = 0;
for i = 1:length(l)
if strcmp( 'line', get(l(i), 'type' ))
if strcmp(get(l(i),'linestyle'),'-')
X = X + 1;
LINE = [LINE;l(i)];
SI = rem(X,length(styles));
if SI == 0
Add = 1;
end
set(l(i),'linestyle', styles(SI+Add,:));
end
end
end
end
% Construct the PRTCMD.
PRTCMD = 'print';
for x = 1:nargin
PRTCMD = [PRTCMD,' ',eval(['a',int2str(x)])];
end
% Discard the changes so that the Figure is not
% updated.
drawnow discard
eval(PRTCMD)
% RESET THE LINESTYLES
set(LINE,'linestyle','-')
% Discard the changes so that the Figure is not
% updated.
drawnow discard
You can set the default color order for the axes by doing the following:
set(gca,'ColorOrder',A)
where A is an RGB vector of any length.
There is a property of the figure window called Position where the x-position, y-position, width, and height are stored. To change this, do the following:
pos=[x_position, y_position, width, height]; set(gcf,'Position',pos)
There is a property of the axis called Visible. You can set Visible to off as follows:
set(gca,'Visible','off')
This is very useful if you want to place text in the figure window with respect to the borders of the figure, rather than with respect to the axes.
There are five different types of units you can use: inches, centimeters, normalized, points, and pixels. To make sure what you get out of your printer looks like what you have on your screen, we recommend using normalized units.
set(gcf,'InvertHardCopy','on')
To change the background color of your plot from black to white, type cinvert at the MATLAB prompt. To make the default setting white, place the following line in your startup.m file
whitebg
To change the color of your figure window to something other than black or white, type the following:
set(gcf,'Color','red')
Yes, in MATLAB version 4.2. A new print command device driver option allows you to save and reload a figure. The command
print -dmfile <filename>
creates two files, filename.m and filename.mat. The M-file contains the necessary object creation and set commands to reproduce the figure. The generated MAT-file also contains the figure data. Handle values are not maintained.
To copy and paste MATLAB figures to the clipboard, select Edit from the menu at the top of the Figure window. Then select Copy. Your figure now exists in the clipboard. To paste, simply choose Paste from the Edit menu in your application.
MATLAB version 4.2 has some functions that will help you do this. See help on dialog for more information.
A CallBack is the specified action that MATLAB performs when the user selects the menu item to which the CallBack has been assigned. When the button or menu item is selected, the expression contained within the CallBack string is executed. For example:
h=uicontrol('Style','PushButton','String','title',... 'CallBack','disp(''hello'')')'
When you push on the button, hello will be displayed in the MATLAB workspace. The most efficient way to write a CallBack is to make the CallBack a function. That way, the function is stored in RAM and will execute more quickly if you are going to be using the button often.
CallBacks get executed in MATLAB's main workspace.
There is a bug in the waterfall routine which prevents the edgecolor from being accurately represented. To work around this, issue the following two commands:
h=waterfall(peaks); set(h,'edgecolor','w')
This will make the edgecolor for the whole waterfall a constant color and allow printing as well as display.
To change the ratio of the axis in a 3-D plot, you will need to change the xform property of the current axis. The property transforms the 3-D data to be plotted on the 2-D screen. The following M-file will do the trick.
function aspect3(x,y,z) v = get(gca,'xform'); d = diag([x y z 1]); set(gca,'xform',v*d);
MATLAB determines the order in which patches are drawn by using the Painter's Algorithm. It determines which patch to draw first by determining which vertices of each patch are closest to you, the viewer. If a few patches have overlapping vertices, then MATLAB must choose which patch to draw first. Sometimes it chooses incorrectly.
Here is an example:
% Place a gray PCOLOR of PEAKS and hsv SURF of PEAKS in
% the same plot.
clf
hold off
% Set the colormap
colormap([gray(30);hsv(30)])
% Generate the data
= peaks(30);
% Create the Cdata for the PCOLOR and SURFACE plot.
% The Cdata for each plot should be contiguous, and
% not overlap. This will guarantee that they use
% different regions of the colormap.
cd1 = z + abs(min(min(z)));
cd2 = cd1 + max(max(cd1)) + 1;
% Place the PCOLOR
P = pcolor(cd1);
shading interp
% Change the location so that it will be visible when
% the SURFACE is drawn
set(P,'zdata', -30*ones(size(get(P,'zdata'))))
hold on
% Place the SURFACE plot
S = surf(1:30,1:30,z,cd2);
% Change the location so that it does not overlap the
% PCOLOR
%set(S,'zdata',15+get(S,'zdata'))
% Change the Clim used by AXES
set(gca,'clim',[min(min(cd1)), max(max(cd2))])
% Make sure that the VIEW and AXES limits are correct
view(3)
axis([1 30 1 30 -30 30])
% Rules that you need to follow when doing this.
%
%1) The Cdata values for each plot should
%not overlap.
%
%2) The range between the minimum and maximum
%values in Cdata should be the same for each
%plot.
%
%3) The Cdatas must be contiguous.
%
%4) Set Clim for AXES to range from the
%smallest and largest values of the 2 Cdatas.
Each element in the image's CData is used to color a rectilinear patch. The data contains the row of the colormap used to color the patch.
pcolor
is a surface plot and its CData is scaled into the colormap. Each element of the CData corresponds to a vertex in the plot. Therefore, the number of rectangles in pcolor is always one row and column smaller than the actual data.
To print a figure window from the command line, type print. If you would like to use any of the options, type
print -<option>
For more information, type
help print
at the MATLAB prompt.
If you are working on a Macintosh or a PC, you can also print from the File pulldown menu on the Figure window (for Macintoshes, make sure the Figure window is the selected window).
To print a SIMULINK block diagram, type print -f<systemname> at the MATLAB command line. You can use the options found in help print when printing a SIMULINK diagram.
If you are working on a Macintosh or a PC, you can print from the File pulldown menu, just as you would print a figure.
The makers of GhostScript can be contacted at the following: Phone: 617-876-3296 Email: gnu@prep.ai.mit.edu
Quickest way:
Create a directory called C:\GS
Copy all files in the directory $MATLAB\GHOSTSCR\BIN , $MATLAB\GHOSTSCR\PS_FILES, and $MATLAB\GHOSTSCR\FONTS to C:\GS (where $MATLAB represents the MATLAB root directory)
Copy the PostScript file to C:\GS
CD to C:\GS
Execute the command GS386 <postscriptfilename>
where <postscriptfilename> is the whole name, including the .ps extension. If for some reason this doesn't work, try
DOS4GW GS386 <postscriptfilename> .
Clean but somewhat cumbersome:
CD to the $MATLAB\GHOSTSCR\BIN directory
Execute the command
GS386 -I..\PS_FILES -I..\FONTS <postscriptfilename>
where here <postscriptfilename> represents the full path name to the postscript file.
Clean and easy but more permanent:
Add $MATLAB\GHOSTSCR\BIN to your DOS path.
In the AUTOEXEC.BAT file, set an environment variable called GS_LIB as
follows:
set GS_LIB = $MATLAB\GHOSTSCR\PS_FILES;$MATLAB\GHOSTSCR\FONTS
(where $MATLAB is replaced by the MATLAB root directory.) Now to use GhostScript you can type gs386 <postscriptfilename> from any directory.
To print to a file, type the following at the MATLAB prompt:
print -<device> <filename>
If you type
help print
at the MATLAB command line, you will see a list of options. There are two types of options, Windows printing options and miscellaneous options. The miscellaneous options allow you to create an .epsi file (which is an encapsulated PostScript file which can be previewed), append your graph to a file, specify the printer to use, and print a SIMULINK diagram.
In MATLAB version 4.2 there is a GhostScript device for HPGL. If you are using MATLAB 4.1.1, 4.1 or 4.0, this option does not exist. The only way to generate an HPGL format file is on the Windows version where you must specify an HPGL printer driver as your default printer. Then, under the File pulldown menu, select Print. In the lower left-hand corner of the Print box is an option to print to a file. Select this option and then select OK. You will then be prompted for an output filename.
SIMULINK models will always print with Times-Roman of point size 10. You cannot change this from inside MATLAB/SIMULINK. You can edit the PostScript file by hand. Be warned, however, the text will not be centered well. You can look near the top of the drawing commands to find the lines:
/Times-Roman findfont dpi2point mul 0 0 10 dpi2point mul neg 0 0]
The /Times-Roman is the font name you can change. The occurance of 10 on the second line is the point size.
It is not possible to spread your SIMULINK diagram out over more than one page. SIMULINK scales your diagram to fit on one page.
This only works for UNIX (because of the print switch, -s). It has been added to the PC for MATLAB 4.2.
function printsys(sys) open_system(sys); blocks=get_param(sys,'blocks'); = size(blocks); for i=1:r if( get_param([sys,'/',blocks(i,:)],'blocks')~=[] ) open_system([sys,'/',blocks(i,:)]) %disp(blocks(i,:)) print('-s') end end close_system(sys)
This appears to be a problem with the LaserJet IV driver initialization. One way we have found to work around the problem is to print a blank Figure window before printing anything else to the LaserJet. This will print a blank piece of paper, and also has the side effect of properly initializing the driver. After this, you should be able to print without any problems. Note that this blank Figure window only needs to be printed once per Windows session. If you quit and restart Windows for some reason, though, you will need to reprint the blank figure.
This has been fixed in 4.2.
When printing several plots, there is a depletion of the system resources under Windows, and even after exiting MATLAB, the resources are not reallocated. This happens to the point where either you can not print anymore or the machine you are working on crashes.
This is more of a problem with Windows than MATLAB. Windows will not reallocate system resources even after you have exited the application. You have to exit Windows and then restart Windows in order to get all of the system resources back.
This can be reproduced both from MATLAB and from MS EXCEL .
There is no clean solution to this problem other than printing to a file first and then sending the file to the printer.
Microsoft anticipates that Windows 4.0 will do a better job in handling system resources.
Sometimes, when you set the paper position in order to generate a small figure, the output title and axis labels are not printed correctly. You may only see the top or bottom half of the text in question depending on where it is in the figure.
So that axis labels and tick mark labels do not overwrite each other, they are always some absolute distance from the axis line. The one caveat is that axis position is relative to the size of the figure and, when rendering to paper, the PaperPosition. When you've got a really small figure or have set the PaperPosition, the axis is very close in absolute coordinates (i.e., it's only 1/2" away rather than 3/4" from the edge of the window or the clipping edge of PaperPosition). The same thing can be seen by making the window really small. A possible work around:
set(gca,'pos',[.2 .2 .7 .7],'units','norm')
Then adjust your output size to accommodate.
You are probably using the Windows driver or the actual printer driver that came with the printer. Levels 4, 3, 2, and 1 of PCL do not support broken line types. PCL level 5 supports broken line types.
Most other software packages break the lines before presenting them to the printer--we do not. You need to use the GhostScript drivers or use PCL 5, which supports LaserJet 4's and up.
PCL 5---Laser jet 4
PCL 4---Laser jet 4,3
PCL 3---Laser jet 4,3,2
PCL 2---Laser jet 4,3,2,1
In version 4.2 of MATLAB, you have the option of using the Windows/printer drivers to get broken lines but the lines will be thinner. This is a trade off because you get really good fonts from the windows drivers but thin lines and you get less than perfect fonts from the GhostScript drivers but thicker lines. See page 84 of the 4.2 Release Notes.
UNIX Workaround:
Use the command capture , which captures the current figure into a matrix, and then displays it in another figure window using the image command. The new image can then be printed normally (but the uicontrols in the image don't work, obviously). Since this method involves printing a bitmap image of the screen, the printout may not have as high a print resolution as the hardcopy results of the print command.
PC Workaround:
There is no capture command for the PC version. One workaround is to use Windows handling of PRINTSCREEN. Select the figure that you want to print and press Alt-PrintScreen. A copy of the current window will be placed on the clipboard. This image can be pasted into another application for printing. One undesirable attribute of this workaround is that the Windows window titles and menus are included in the image. These sections of the image can be "cut" using Windows PaintBrush program.
To increase the number of surface faces, use griddata :
[xi,yi,zi] = griddata(x,y,z,0:.1:10,0:.1:100)
where x , y, and z are your original data, 0:.1:10 and 0:.1:100 are your new and increased ranges for x and y .
Then use xi , yi , and zi in your surface command.
For more information, see the MATLAB technical note written on this topic. It is located on the ftp site in pub/tech-support/tech-notes/gr1.txt.
You have demo passcodes ( DEMO is located at the end of your encryption codes in your license.dat file)
You have a CPU locked Multi-User License (your hostid is located at the end of your encryption codes in your license.dat file and you have more than key). See page 9 of your Installation Guide if you are running on a VAX or page 1-14 if you are running on a UNIX system.
Install MATLAB from the tape onto each machine, using the install option for STANDALONE/SERVER machines.
For any client machines of the DEC and SUN, make sure the MATLAB client DEC machines have their matlab command access $MATLAB/bin/matlab on the DEC platform. Likewise, SUN MATLAB client machines should have their matlab command access $MATLAB/bin/matlab on the SUN platform.
Decide which machine is the license server. In this example we will consider the DEC machine to be the license server.
The DEC license file should contain the DEC lmhostid, the DEC lm_matlab vendor daemon and passcodes based on the DEC lmhostid.
In the SUN $MATLAB/etc directory, create a link for the license.dat file to point to the DEC $MATLAB/etc/license.dat .
Start the license manager from the DEC license server machine.
Keep in mind that for different platforms to work together, they must be using compatible versions of the license manager. For example, if you have V3.5j on the SUN, you cannot combine it with V4.1 for the DEC since they contain incompatible versions of the license manager. More specifically, the SUN MATLAB will call lmgrd on the DEC and place it in an incompatible state. It will not be able to run properly.
---------------------------------------------------------------------------- p>#License file for use with FLEXlm version 2.4c.
SERVER pooh 55419ab7 1705
SERVER piglet 554251b8 1705
SERVER rabbit 52006ac1 1705
DAEMON MLM /usr/local/matlab/etc/lm_matlab
FEATURE MATLAB MLM 1 01-jun-2012 99 6B283ACADCE90BE190B7 ""
FEATURE SIMULINK MLM 1 01-jun-2012 99 EB689A7AE885CDB2E0A3 ""
----------------------------------------------------------------------------
To bring up the three license managers interactively, do the following after installation.
Login to pooh. Become root. cd /usr/local/matlab/etc . Run lmstart .
Login to piglet. Become root. cd /usr/local/matlab/etc . Run lmstart.
Login to rabbit. Become root. cd /usr/local/matlab/etc . Run lmstart .
To have the license manager daemons started at boot time, follow the directions in the Installation Guide to place the Bourne shell code fragment into the appropriate boot script.
The /etc/lmboot link must exist on each of the servers. To create this link on a given server, first login to the server and then, as root, run:
# $MATLAB/etc/lmboot -s
where $MATLAB is the location of the MATLAB root directory.
Please note that at least two of the machines must always be running in order to create a network quorum. If only one of the three machines is running, no licenses will be available until a second server regains a running status.
The order of the servers is also important. The first server will be the primary server and if this machine fails, the primary server will be designated as the next server listed in the license file.
You must submit all three servers' hostids in order for the passcodes to be be properly generated for this configuration.
V2.4c of the license manager offered the option to enable multiple FEATURE lines of the same name into one license.dat file.
For this to work, it is necessary to place all the floating license FEATURE lines before all the node-locked FEATURE lines.
To start other vendors' daemons you must create:
A merged license.dat file with all the DAEMON and FEATURE lines associated with each vendor daemon.
A modified $MATLAB/etc/lmboot script. After installation the lmboot script needs to be modifed to know about each additional vendor daemon in the license file. This is so that the temporary license file in /usr/tmp can be created correctly.
This example demonstrates what needs to be done. Consider having both MATLAB and another vendor's daemons started by MATLAB's license manager daemon with the following license file:
---------------------------------------------------------------------------- p>#License file for use with FLEXlm version 2.4c.
SERVER radical 52201985 1700
#
DAEMON MLM /usr/local/matlab/etc/lm_matlab
FEATURE MATLAB MLM 1 01-aug-1995 3 6B486F9FDB9F99083820 ""
FEATURE SIMULINK MLM 1 01-aug-1995 3 8B38FF3F695F028F93A8 ""
FEATURE Control_Toolbox MLM 1 01-aug-1995 3 2B18BFEF0BB457E414B5 ""
#
DAEMON XXX /usr/local/XXX/license/bin/XXX
FEATURE XXX XXX 3.100 01-aug-1995 1CBB4ACD78C0C77ABE123 ""
----------------------------------------------------------------------------
You need to remember the DAEMON names when making the code changes. In this case the only additional DAEMON name is XXX .
Below is a Bourne shell code section from lmboot . The part between the
"======" lines must be modifed. For each DAEMON you must add three lines such as:
NAME)
ln -s $daemonPath /usr/tmp/$marker.vd$ndaemon
;;
The only thing that should change is NAME . It must be the name of the DAEMON. For PVI it would be
PVI)
ln -s $daemonPath /usr/tmp/$marker.vd$ndaemon
;;
Note that these lines for PVI are already shipped in the script, except the lines are commented out. To activate them simply remove the # or comment character from the beginning of the lines as indicated below. If there are additional daemons, then three more lines for each daemon must be added.
In order for the process command names given by the ps command to look the same across platforms, the symbolic link created in the three-line script section above should refer to a binary daemon program, not a script. This means the daemon path given by the third field of the DAEMON line (referred to as $daemonPath in the script) should be a path to a binary program. Note that for MATLAB this is not true. So a special value for the daemon path which refers directly to the binary is used.
#
#Create temporary license.dat file by copying and modifying the original file
#
rm -f /usr/tmp/$marker.dat > /dev/null 2>&1
rm -f /usr/tmp/$marker.vd* > /dev/null 2>&1
ndaemon=0;
(while read line
do
field1=`echo $line | awk '{print $1}'`
if [ "$field1" = "DAEMON" ]; then
daemonName=`echo $line | awk '{print $2}'` # field 2
daemonPath=`echo $line | awk '{print $3}'` # field 3
ndaemon=`expr $ndaemon + 1`
case "$daemonName" in
# Always assume $MATLAB/etc/$Arch/lm_matlab
# Must use the binary - NO SCRIPTS
ln -s $MATLAB/etc/$Arch/lm_matlab /usr/tmp/$marker.vd$ndaemon
;;
#============================================================
# ADD OTHER DAEMONS HERE. Example, PV-WAVE. Uncomment lines.
# Add other case statments for additional daemons.
#
PVI) # Use the daemonPath - arch binary already
ln -s $daemonPath /usr/tmp/$marker.vd$ndaemon
;;
#============================================================
*) # daemons you forgot
ndaemon=`expr $ndaemon - 1`
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo ''
echo 'Sorry! Skipped following DAEMON line. Fix $MATLAB/etc/lmboot script.'
echo ''
echo "$line"
echo ''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
continue
;;
esac
echo "$line" | sed "s%$daemonPath%/usr/tmp/$marker.vd$ndaemon%"
>> /usr/tmp/$marker.dat
else
echo "$line" >> /usr/tmp/$marker.dat
fi
done) < $licensefile
MATLAB
TOOLBOX
When installed as described by the installation document, the logical names are defined on a system-wide basis at boot time through the execution of MATLAB:[ETC]MATLAB_SYSTARTUP.COM from SYS$MANAGER:SYSTARTUP_V5.COM . (See installation guide steps 8)
Symbols used to invoke MATLAB and its utilities, such as CMEX, are defined on a per-process basis through the execution of MATLAB:[ETC]MATLAB_SYLOGIN.COM from SYS$MANAGER:SYLOGIN.COM at login time. (See Installation Guide step 9)
If you want to maintain a MATLAB v3.5 environment and have the ability to run MATLAB v4.x, omit steps 8 and 9 of the installation procedure. Instead, following completion of the installation procedure, perform the following steps using the editor of your choice:
Copy the lines from MATLAB_SYSTARTUP.COM which define the logical names MATLAB and TOOLBOX to MATLAB_SYLOGIN.COM . The lines in MATLAB_SYSTARTUP.COM look like this:
$ DEFINE/SYSTEM/EXEC/TRANS=CONCEALED MATLAB DISK$USER:[MATLAB.]
$ DEFINE/SYSTEM/EXEC/TRANS=CONCEALED TOOLBOX DISK$USER:[MATLAB.TOOLBOX.]
Place these lines so they are the first commands to executed by the file.
From these lines remove the "/SYSTEM" qualifier, so they look like this:
$ DEFINE/EXEC/TRANS=CONCEALED MATLAB DISK$USER:[MATLAB.]
$ DEFINE/EXEC/TRANS=CONCEALED TOOLBOX DISK$USER:[MATLAB.TOOLBOX.]
Save MATLAB_SYLOGIN.COM and exit. (Do not save MATLAB_SYSTARTUP.COM .)
Now to setup the environment to run V4.x simply type: @DISK$USER:[MATLAB.ETC]MATLAB_SYLOGIN
Check whether the license daemons are running. Do a ps as indicated in the troubleshooting section of the Installation Guide.
If the license daemons are not running, you should execute lstmart . With a CPU-locked Multi-User license, however, the license daemons do not need to be run, so you should try starting MATLAB and let us know if you're getting any errors.
Check that the DAEMON line in the license.dat file is pointing to the correct location for lm_matlab .
Make sure the host name on the SERVER line in the license.dat file is correct.
Make sure the the UNIX ping <hostname> command returns <hostname> is alive where hostname is the name of the MATLAB server machine. If the ping command returns the error, <hostname> is not responding , then there is a problem with your network configuration such that connection to that machine will fail. Connection to the license daemons will, therefore, also fail.
Make sure that the network software TCPIP is running on your machine. Even for stand-alone machines, the license manager requires TCPIP.
It may be a typographical error in the feature line indicated by the error. For example, this error will occur if Signal_Toolbox is entered as signal_toolbox . Check the error message for typographical errors and case sensitivity in the name of the feature. Make sure the FEATURE line matches the passcodes as generated by The MathWorks, Inc.
The user is running the matlab executable in, say, $MATLAB/bin/sun4, rather than the matlab script in $MATLAB/bin. Note that sun4 can be replaced with any architecture we support, like RS/6000.
You may have the wrong matlab on the UNIX path or you may need to rerun install_matlab to set up the correct paths.
You do not have TCPIP software on your machine. To check, execute the UNIX ping command. e.g., ping <hostname> where hostname is the name of the machine from which you're trying to run MATLAB. If ping is successful, see (2) below.
You probably do not have 1700 at the end of the SERVER line in the license.dat file.
You probably installed the latest version of MATLAB (which uses FLEX 2.4c) without shutting the old (v2.21) license daemons.
This error indicates that you are running a version of FLEXlm older than 2.4c. You need to execute lmstart in V4.1 of MATLAB which executes the lmgrd and lm_matlab license daemons which ship with MATLAB 4.1.
You probably received new codes and did not restart the license manager. You can also try doing an lmreread .
Make sure you do not have a typographical error in the FEATURE line spelling.
The problem occurs with the logical LM_LICENSE_FILE set to NODE:FILE_SPEC.
MATLAB compiled with the VAX C compiler does not support accessing a license file through DECNET. This is because access to the license file is checked with a C standard runtime library routine called access. The VAX C runtime library access routine explicitly does not support access to a file through DECNET.
LM_LICENSE_FILE must point to a local license.dat file. This license.dat can be a VAX CLUSTER file, which is the equivalent of NFS mounting under UNIX.
If you are working on a Macintosh or a PC, you can print from the File menu, just as you would print a figure.
The Function block can use only a limited number of functions (the list of these functions can be found by clicking on Help in the function block). This block uses C routines to perform the calculations and is therefore very fast.
The following is an S-function example, which was written by one of the Technical Support Engineers:
function[sys,x0]=show(t,x,u,flag) if abs(flag)==0, hs1=figure('units','normal','pos',[.8 .8 .1 .2]); hs2=uicontrol(hs1,'style',... 'edit','units','normal','pos',[0 0 1 1], ...'min',0,'max',100); set(hs2,'string','DIG_SCOPE'); sys=[0 1 0 1 0 0]; x0= hs2; elseif abs(flag)==2, tempstr=get( x(1) , 'string' ); newstr=str2mat( num2str(u),tempstr ); % Keep the last 50 values [m n]=size(newstr); if m>50, newstr=newstr(1:50,:); end set( x(1) , 'string', newstr); sys= x(1); else sys=[]; end
Aside from the examples, which can be found in the directory /simulink/blocks , our engineers are starting to build a library of examples. To find out more about these, contact support@mathworks.com .
There is a technical note, which contains a list of compilers along with many addresses and phone numbers for compiler companies. This technical note can be found in pub/tech-support/tech-notes/mxeng1.txt.
A descripton of how to create C++ MEX-file functions is in a technical note which can be found on the ftp server in pub/tech-support/tech-notes/mxeng5.txt.
#include <stdio.h> #include "engine.h" int main( void ) { Engine * ep; char * buffer; double userdata[3]; int i; for (i=0;i<3;i++) { printf("Enter element #%d: ",i+1); scanf("%lf",&userdata[i]); } ep=engOpen("setenv DISPLAY puff:0; matlab"); if(ep==NULL) { fprintf(stderr,"Error opening MATLAB"); exit(-1); } if engPutFull(ep,"mystuff",1,3,userdata,NULL) fprintf(stderr,"Error entering data into MATLAB"); buffer=mxCalloc(201,sizeof(char)); engOutputBuffer(ep,buffer,200); if(engEvalString("hankel(mystuff)")) fprintf(stderr,"Error using hankel"); else printf("Hankel Matrix was \n%s\n",buffer); mxFree(buffer); engClose(ep); }
Segmentation violation errors occur when MATLAB tries to write to an area of memory that is not allowed. Some possible causes of this are improper dereferencing of pointers, use of pointers which contain incorrect values, and writing past the end of a dimensioned array. You should check your MEX-file function to see if any of these possibilities are occurring.