| Contents | Index |
MuPAD® does not provide for many tools to import standard graphical vector formats, yet. Presently, the only supported vector type is the stl format, popular in Stereo Lithography, which encodes 3D surfaces. It can be imported via the routine plot::SurfaceSTL.
In contrast to graphical vector formats, there are many standard bitmap formats such as bmp, gif, jpg, ppm etc. that can be imported. One can read such a file via import::readbitmap, thus creating a MuPAD array of RGB color values that can be manipulated at will. In particular, it can be fed into the routine plot::Raster which creates an object that can be used in any 2D MuPAD plot. Note, however, that the import of bitmap data consumes a lot of memory, i.e., only reasonably small bitmaps (up to a few hundred pixels in each direction) should be processed.
In the following example, we plot the probability density function and the cumulative density function of the standard normal (“Gaussian”) distribution. Paying tribute to Carl Friedrich Gauss, we wish to display his picture in this plot. Assume that we have his picture as a ppm bitmap file “Gauss.ppm.” We import the file via import::readbitmap that provides us with the width and height in pixels and the color data:
[width, height, gauss] := import::readbitmap("Gauss.ppm"):
We have to use Scaling = Constrained to preserve the aspect ratio of the image. Unfortunately, this setting is not appropriate for the function plots. So we use two different scenes that are positioned via Layout = Relative in one canvas (see section Layout of Canvas and Scenes).
The first scene plots the two functions using the default setting Scaling = Unconstrained for function plots. With the sizes Width = 1, Height = 1, representing fractions of the canvas size, this scene fills the whole canvas.
The second scene is given a width and height of approximately the desired magnitude. It uses Scaling = Constrained to get the aspect ratio right, automatically. With the attributes Bottom and Left, the lower left corner of Gauss' image is moved to an appropriate point of the canvas:
pdf := stats::normalPDF(0, 1):
cdf := stats::normalCDF(0, 1):
plot(plot::Scene2d(plot::Function2d(pdf(x), x = -4..7),
plot::Function2d(cdf(x), x = -4..7),
Width = 1, Height = 1),
plot::Scene2d(plot::Raster(gauss),
Scaling = Constrained,
Width = 0.3, Height = 0.6,
Bottom = 0.25, Left = 0.6,
BorderWidth = 0.5*unit::mm,
Footer = "C.F. Gauss",
FooterFont = [8]),
Layout = Relative
):


Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |