krj@na.toronto.edu (Ken Jackson) (01/03/90)
Comment: requests, comments or problems to matlab-users-request@mcs.anl.gov
Comment: submissions to matlab-users@mcs.anl.gov
Comment: library contributions to matlab-library@mcs.anl.gov
Matlab Digest Tuesday, December 19, 1989 Volume 1 : Issue 3
Today's Editor: Chris Bischof
Today's Topic:
Matlab codes from Netlib
Suppressing blackened surface plots
Putting axes on `mesh' plots
Including Matlab plots in TEX files
Moving Average Filter
----------------------------------------------------------------------------
From: Christian Bischof (bischof@mcs.anl.gov)
The matlab codes have now been installed in Netlib. Thanks to Jack
Dongarra for his help. In order to get an idea how you can get
codes from netlib, and what other useful goodies you can find there,
send the message
send index
to
netlib@ornl.gov
If you want to get the index for the `matlab' subdirectory,
you would for example send the message
send index from matlab
If you want to get the index from the `tools' subdirectory in
`matlab', say, you would send the message
send index from matlab/tools
Now let's assume that you want the file `decode.f' from the
`tools' subdirectory. Then you send the message
send decode.f from matlab/tools.
Currently there are the following subdirectories in Matlab:
approximation approximation theory
archive old matlab user group messages
control control theory
dataanalysis data analysis and statistics
graphics graphics programs
integration numerical integration
linearalgebra linear algebra utilities
misc miscellaneous
ode ordinary differential equations
optimization as the name says
pde partial differential equations
rootfinding zero-finding routines
specialfunctions special functions
teaching for classroom use
tools miscellaneous tools
Currently we have the following software:
In `approximation':
conforma: A set of functions which can be used to compute
rational (Pade' type) approximations to functions
which are analytic inside the unit circle.
Howard Wilson, University of Alabama
In `archive':
v1no1 and v1no2: The first two messages I sent out since
I monitor distribution
In `dataanalysis':
qqnormal: Q-Q plot to analyze distribution of data errors
and residuals.
Peter Shaw
In `linearalgebra':
gjordanrounded: Gauss-Jordan reduction with prescribed
number of digits machine accuracy.
Howard Wilson, University of Alabama
In `misc':
choas: Chaotic behavior associated with logistic equation
Howard Wilson, University of Alabama
polyhedr: geometrical and inertial properties of an
arbitrary polyhedron.
Howard Wilson, University of Alabama
In `ode':
ode78: adaptive seventh- and eigth order Runge-Kutta integrator
with an example for the forced harmonic motion of a forced
pendulum.
Howard Wilson, University of Alabama
In `optimization':
nelder: unconstrained nonlinear search procedure to perform
a curve fit to data.
Howard Wilson, University of Alabama
simplex1: simplex method for linear programming
Henry Wolkowicz, University of Waterloo
In `pde':
beam: impact dynamics problem for an elastic Euler beam
of constant cross section which is simply supported
at each end.
Howard Wilson, University of Alabama
In `teaching':
teaching.tex: TEX source for `The MATLAB Primer' by
Kermit Sigmon, University of Florida
In `tools':
bundle: csh script used to bundle matlab source files
unbundle: csh script used to unbundle matlab files from
netlib.
decode.f: Fortran program for mapping (*, *) and ** back
to proper matlab notation
eps2tex.shar: tool to resize, properly position, and include
postscript files in TEX documents.
Christian Bischof, Argonne National Laboratory
I want to stress that I do not check the routines for numerical
robustness, good coding style or the like. If you dont' like the
way a certain routine works, talk to the author. And, as usual
with free software, there are no guarantees that it will work
the way you expect it to.
Further, it is important that you remap
(* to left_bracket
*) to right_bracket
** to caret
after getting the code from netlib and splitting it into seperate
files. A global replace in a text editor will do, otherwise you
can use the `decode.f' function in matlab/tools.
For those on Unix systems, the `unbundle' shell script in the
`tools' directory will strip headers from the netlib message,
separate the matlab files, and remap the special characters.
Now that the library is in place, I think it would be a good
time to dust off and clean up your matlab code that you think
might be useful for others. If you have a unix system, please
get yourself the `bundle.shar' file and run it on the files you
want to submit to make sure that after substitutions no line is
longer than 80 characters and that indentation still looks good
after tabs have been replaced by blanks. At any rate, please write
me a little README file and indicate in which directory you
want your code to be placed.
Looking forward to your submissions
-- Chris Bischof
----------------------------------------------------------------------
>From trummer@cs.sfu.ca (Manfred Trummer) Tue Dec 5 19:27:59 1989
Subject: surface plots
In reply to Dan Loziers question on MATLAB surface plots:
To avoid getting blackened surface plots I just remove
rows (or columns or both) from my original matrix.
To plot a 16 x 1000 matrix W I would use
mesh(compactify(W',27)'),
thus plotting only a 16x37 submatrix.
To plot a 161 x 161 matrix Z you can use
mesh(compactify(compactify(Z',4)',4))
and so on. You can easily modify the M-file to do
row and column compactification at once, but since this
does not seem to be as useful in practice I go with
fewer input parameters.
Cheers,
--Manfred Trummer
function v=compactify(u,P);
% u,v: matrices; P: integer
% delete every P-th row of u to obtain v
% Default for P: P = 2 (delete every second row).
%
% This M-file can be called to suppress lines in a surface plot using mesh.
% To delete columns instead of rows call v=compactify(u',P)'.
%
% v=compactify(u) or v=compactify(u,P)
%
% Manfred Trummer, Mathematics Department
% Simon Fraser University, Burnaby, B.C., Canada
% <trummer@cs.sfu.ca>
%
if nargin==1 P=2; end;
s=size(u); nl=fix((s(1)-1)/P);
index=P*[0:nl]+ones(1,nl+1);
v=u(index,:);
%END
----------------------------------------------------------------------------
>From scroggs@icase.edu (Jeff Scroggs) Wed Dec 6 08:35:59 1989
Subject: Axis using Dore on Titan
Does anybody in matlabland know how to put axis on the color
surface rendering available in matlab with the 'render' command?
I have discovered that surface plots from the 'mesh' command
can have axis inserted with the following m-file
-- Jeff Scroggs
% this function puts axis and labels of axis on a 3-D plot
% assumes the thing being plotted is between -1 and +1
% the 'hold' command must be executed first
% be sure the scaling is not default
axis([0 1 0 1])
x0 = -.3 ;
y0 = .0 ;
xt = y0 ;
yt = x0 ;
% x axis
r = [ x0+0.53 x0+0.25 ] ;
x = [ y0+0.0 y0+0.44 ] ;
plot(x,r) ;
text(xt+.2,yt+0.35,'x') ;
% y axis
r = [ x0+0.53 x0+0.75 ] ;
x = [ y0+0.0 y0+0.55 ] ;
plot(x,r) ;
text(xt+0.3,yt+0.67,'y') ;
% z axis
r = [ x0+0.53 x0+1.0 ] ;
x = [ y0+0.0 y0+0.0 ] ;
plot(x,r) ;
text(xt-0.03,yt+0.75,'z') ;
-----------------------------------------------------------------------
>From demmel@robalo.nyu.edu (Jim Demmel) Thu Dec 7 08:49:05 1989
Subject: Question on matlab & latex
How does one merge matlab plots into a latex file? I have tried various
suggestions from other sites, and have yet to get the plot to appear
where I want it, if it appears at all. It may be local differences between
latexes or file system organizations. Could someone post a small example
which shows explicitly how to do it? Advice on rescaling the plot would be
welcome too.
Jim Demmel
[ moderators note: ]
[ eps2tex.shar in matlab/tools contains the eps2tex command which ]
[ works well on our configuration: Arbortex TeX and Apple Laser- ]
[ writer. -CHB ]
------------------------------------------------------------------------
From: Jack Sharer <JWS%PSUARL.BITNET@ANLVM.CTD.ANL.GOV>
Subject: Moving Average Filter
I was suprised to find that MatLab's signal processing toolbox does not
include a simple moving average filter or box car filter. I've been
using the following function to implement a moving average filter:
function ANSWER = SMOOTH (X, N)
% X is the vector we want to which we apply a moving average
% N is filter period
% Note: code for handling a length 1 vector is omitted
ANSWER = cumsum(X);
ANSWER = [ ANSWER(N); (ANSWER( N+1 : Length(ANSWER)) - ...
ANSWER( 1 : Length(ANSWER) - N) ) ] ./ N;
Can any of you offer a more efficient algorithm?
----------------------------------------------------------------------
<end of matlab digest>
---------------------
Reposted by
Prof. Kenneth R. Jackson, krj@na.toronto.edu (on Internet, CSNet,
Computer Science Dept., ARPAnet, BITNET)
University of Toronto, krj@na.utoronto.ca (on CDNnet and other
Toronto, Ontario, X.400 nets (Europe))
Canada M5S 1A4 ...!{uunet,pyramid,watmath,ubc-cs}!utai!krj
(Phone: 416-978-7075) (on UUCP)
(FAX: 416-978-4765)