
| Contents | Index |
• Desktop Tools and Development Environment
• Graphics
• Lighting as a Visualization Tool
• Creating 3-D Models with Patches
• Volume Visualization Techniques
Selecting Visualization Techniques
Steps to Create a Volume Visualization
Volume Visualization Functions
Example - Ways to Display MRI Data
Example - Adding Isocaps to an Isosurface
Using Scalar Techniques with Vector Data
Specifying Starting Points for Stream Plots
Accessing Subregions of Volume Data
1. Determine the Range of the Coordinates
2. Add Slice Planes for Visual Context
3. Add Contour Lines to the Slice Planes
4. Define the Starting Points for the Stream Lines
1. Select a Subset of Data to Plot
2. Calculate Curl Angular Velocity and Wind Speed
4. Define the View and Add Lighting
1. Load Data and Calculate Required Values
3. Add Contour Lines to Slice Planes
1. Specify Starting Points of the Data Range to Plot
2. Create Stream Lines to Indicate Particle Paths
4. Calculate the Stream Particle Vertices
2. Add Isocaps to the Isosurface
• Creating Graphical User Interfaces
• About the Simple GUIDE GUI Example
• Lay Out the Simple GUI in GUIDE
• Program the Simple GUIDE GUI
• Use the Completed Simple GUIDE GUI
Create the Simple Programmatic GUI Code File
• Lay Out the Simple Programmatic GUI
• Code the Simple Programmatic GUI
• Use the Completed Simple Programmatic GUI
A Working GUI with Many Components
Add Components to the GUIDE Layout Area
Define User Interface Controls
Define Panels and Button Groups
• Designing for Cross-Platform Compatibility
• Default Callback Properties in GUIDE
• Customizing Callbacks in GUIDE
• Add Code for Components in Callbacks
• Making Multiple GUIs Work Together
Example - Manipulating a Modal Dialog Box for User Input
Example - Individual GUIDE GUIs Cooperating as Icon Manipulation Tools
• GUI for Animating a 3-D View (GUIDE)
About the 3-D Animation Example
View and Run the 3-D Globe GUI
• GUI to Interactively Explore Data in a Table (GUIDE)
• List Box Directory Reader (GUIDE)
• Access Workspace Variables from a List Box (GUIDE)
• A GUI to Set Simulink Model Parameters (GUIDE)
About the Simulink Model Parameters Example
View and Run the Simulink Parameters GUI
How to Use the Simulink Parameters GUI
Program the Slider and Edit Text Components
• An Address Book Reader (GUIDE)
About the Address Book Reader Example
View and Run the Address Book Reader GUI
Run the Address Book Reader GUI
Load an Address Book Into the Reader
The Contact Phone Number Callback
Page Through Address Book - Prev/Next
• Use a Modal Dialog Box to Confirm an Operation (GUIDE)
About the Modal Dialog Example
View and Run the Modal Dialog Box GUIs
Set Up the Close Confirmation Dialog
Set Up the GUI with the Close Button
• Time Data Updates from a GUI (GUIDE)
• Create and Run a Programmatic GUI
Create Figures for Programmatic GUIs
• Add Components to a Programmatic GUI
• Compose and Code GUIs with Interactive Tools
Set Positions of Components Interactively
Set Font Characteristics Interactively
• Set Tab Order in a Programmatic GUI
• Create Menus for a Programmatic GUI
• Create Toolbars for Programmatic GUIs
• Design Programmatic GUIs for Cross-Platform Compatibility
• Initialize a Programmatic GUI
• Examples: Program GUI Components
• Share Data Among a GUI's Callbacks
• GUI with Axes, Menu, and Toolbar
About the Axes, Menu, and Toolbar Example
View and Run the AxesMenuToolbar Code
Generate the Graphing Commands and Data
• GUI that Displays and Graphs Tabular Data
View and Run the tableplot Code
Set Up and Interact with the uitable
Handle Graphics Property Browser
Why Write Custom Applications?
Exchanging Data Files Between Platforms
Overview of matimport.c Example
Declare Variables for External Data
Read External Data into mxArray Data
Creating a MAT-File in Fortran
Building on Windows Operating Systems
Deploying MAT-File Applications
Limitations to Shared Library Support
Troubleshooting Shared Library Applications
Examples of Passing Data to Shared Libraries
Manually Converting Data Passed to Functions
Constructing a libpointer Object
Creating a Pointer to a Primitive Type
Creating a Pointer to a Structure
Passing a Pointer to the First Element of an Array
Putting a String into a Void Pointer
Memory Allocation for an External Library
Working with Structures Examples
Example of Passing a MATLAB Structure
Using the Structure as an Object
Introduction to Source MEX-Files
Overview of Creating a Binary MEX-File
Using Help Files with MEX-Files
Workspace for MEX-File Functions
Selecting a Compiler on Windows Platforms
Selecting a Compiler on UNIX Platforms
Overview of Building the timestwo MEX-File
Understanding MEX-File Problems
Compiler and Platform-Specific Issues
Custom Building on UNIX Systems
Custom Building on Windows Systems
Creating a MEX-File Using LAPACK and BLAS Functions
Preserving Input Values from Modification
Passing Arguments to Fortran Functions from C/C++ Programs
Passing Arguments to Fortran Functions from Fortran Programs
Handling Complex Numbers in LAPACK and BLAS Functions
Modifying the Function Name on UNIX Systems
MEX Uses 32-Bit API by Default
How to Upgrade MEX-Files to Use the 64-Bit API
Passing Two or More Inputs or Outputs
Passing Structures and Cell Arrays
Handling 8-, 16-, and 32-Bit Data
Manipulating Multidimensional Numerical Arrays
Calling Functions from C/C++ MEX-Files
Using C++ Features in MEX-Files
Debugging on the Microsoft Windows Platforms
Building Cross-Platform Applications
Specifying Constant Literal Values
Replacing fseek and ftell with 64-Bit Functions
Determining the Size of an Open File
Determining the Size of a Closed File
Using the Fortran %val Construct
Passing Two or More Inputs or Outputs
Calling Functions from Fortran MEX-Files
Debugging on Microsoft Windows Platforms
Building Cross-Platform Applications
What You Need to Build Engine Applications
Calling MATLAB Software from a C Application
Calling MATLAB Software from a C++ Application
Calling MATLAB Software from a Fortran Application
Attaching to an Existing MATLAB Session
Building and Running Engine Applications on Windows Operating Systems
Windows Engine Example engwindemo
Building and Running Engine Applications on UNIX Operating Systems
Files Required by Engine Applications
Debugging MATLAB Functions Used in Engine Applications
Benefits of the MATLAB Java Interface
Who Should Use the MATLAB Java Interface
To Learn More About Java Programming Language
Platform Support for JVM Software
Using a Different Version of JVM Software
Making Java Classes Available in MATLAB Workspace
Loading Java Class Definitions
Locating Native Method Libraries
Java Classes Contained in a JAR File
Saving and Loading Java Objects to MAT-Files
Finding the Public Data Fields of an Object
Accessing Private and Public Data
Determining the Class of an Object
Invoking Static Methods on Java Classes
Obtaining Information About Methods
Java Methods That Affect MATLAB Commands
How MATLAB Software Handles Undefined Methods
How MATLAB Software Handles Java Exceptions
Method Execution in MATLAB Software
How MATLAB Software Represents the Java Array
Creating an Array of Objects in MATLAB Software
Accessing Elements of a Java Array
Creating a New Array Reference
Creating a Copy of a Java Array
Conversion of MATLAB Argument Data
Passing Data to Overloaded Methods
Conversion of Java Return Types
Converting Objects to MATLAB Types
Description of Function phonebook
Description of Function pb_lookup
Description of Function pb_add
Description of Function pb_remove
Description of Function pb_change
Description of Function pb_listall
Description of Function pb_display
Description of Function pb_keyfilter
Benefits of the MATLAB .NET Interface
Why Use the MATLAB .NET Interface?
What's the Difference Between the MATLAB .NET Interface and MATLAB Builder NE?
Using a .NET assembly in MATLAB
To Learn More About the .NET Framework
Loading .NET Assemblies into MATLAB
What Classes Are in a .NET Assembly?
Using the delete Function on a .NET Object
How MATLAB Maps C# Property and Field Access Modifiers
Call .NET Methods with Optional Arguments
Calling .NET Extension Methods
Call .NET Properties That Take an Argument
How MATLAB Represents .NET Operators
Limitations to Support of .NET Methods
Limitations to Support of .NET Events
Handling Data Returned from a .NET Object
Accessing .NET Array Elements in MATLAB
Converting .NET Arrays to Cell Arrays
Limitations to Support of .NET Arrays
Call a .NET Delegate in MATLAB
Create a Delegate from a .NET Object Method
Create a Delegate Instance Bound to a .NET Method
Use .NET Delegates With the out and ref Type Arguments
Combine and Remove .NET Delegates
Calling a .NET Method Asynchronously
Limitations to Support of .NET Delegates
Iterate Through a .NET Enumeration
Use .NET Enumerations to Test for Conditions
Example - Read Special System Folder Path
Use Bit Flags with .NET Enumerations
Limitations to Support of .NET Enumerations
Work with Microsoft Word Documents Using .NET
Accessing Items in a .NET Collection
Convert a .NET Collection to a MATLAB Array
Display .NET Generic Methods Using Reflection
Create .NET Object From Constructor
View Information About .NET Object
Introduction to .NET Data Types
Use .NET Numeric Types in MATLAB
Do Not Use ClassName.PropertyName Syntax for Static Properties
Call .NET Methods That Use the out Keyword
Call .NET Methods That Use the ref Keyword
Call .NET Methods That Use the params Keyword
Create a Cell Array for Each System.Object
Create MATLAB Variables from the .NET Data
Call MATLAB Functions with MATLAB Variables
The MATLAB COM Automation Server
Registering Controls and Servers
Overview of MATLAB COM Client Examples
Example - Using Internet Explorer Program in a MATLAB Figure
Example - Grid ActiveX Control in a Figure
Example - Reading Excel Spreadsheet Data
MATLAB Client and In-Process Server
MATLAB Client and Out-of-Process Server
COM Implementations Supported by MATLAB Software
Client Application and MATLAB Automation Server
Client Application and MATLAB Engine Server
Identifying Objects and Interfaces
Setting the Value of a Property
Using Enumerated Values for Properties
Properties That Take Arguments
Exceptions to Using Implicit Syntax
Specifying Enumerated Parameters
Returning Multiple Output Arguments
Argument Callouts in Error Messages
Functions for Working with Events
Responding to Events - an Overview
Responding to Events - Examples
Writing Event Handlers as MATLAB File Subfunctions
Releasing COM Interfaces and Objects
Handling Data from a COM Object
Passing MATLAB Data to ActiveX Objects
Passing MATLAB SAFEARRAY to COM Object
Reading SAFEARRAY from a COM Object in MATLAB Applications
Displaying MATLAB Syntax for COM Objects
Using a MATLAB Application as an Automation Client
Connecting to an Existing Excel Application
Running a Macro in an Excel Server Application
Using Microsoft Forms 2.0 Controls
Using MATLAB Application as a DCOM Client
MATLAB COM Support Limitations
Connecting to an Existing MATLAB Server
Executing Commands in the MATLAB Server
Exchanging Data with the Server
Terminating the Server Process
Specifying a Shared or Dedicated Server
Using MATLAB Application as a DCOM Server
Example - Viewing Methods from a Visual Basic .NET Client
Example - Calling MATLAB Software from a Web Application
Example - Calling MATLAB Software from a C# Client
What You Need to Use Web Services with MATLAB
Typical Applications Using Web Services with MATLAB
How MATLAB Accesses Web Services
Example - createClassFromWsdl Function
Tools for Creating Web Services
Supported Serial Port Interface Standards
Using the Examples with Your Device
The Serial Port Interface Standard
Connecting Two Devices with a Serial Cable
Serial Port Signals and Pin Assignments
Finding Serial Port Information for Your Platform
Using Virtual USB Serial Ports
Configuring and Returning Properties
Configuring Properties During Object Creation
The Serial Port Object Display
Creating an Array of Serial Port Objects
Example - Introduction to Writing and Reading Data
Controlling Access to the MATLAB Command Line
Example - Writing and Reading Text Data
Example - Parsing Input Data Using textscan
Example - Introduction to Events and Callbacks
Event Types and Callback Properties
Responding To Event Information
Creating and Executing Callback Functions
Enabling Callback Functions After They Error
Example - Using Events and Callbacks
Signaling the Presence of Connected Devices
Controlling the Flow of Data: Handshaking
Example: Introduction to Recording Information
Creating Multiple Record Files
Example: Recording Information to Disk
Using Serial Port Objects on Different Platforms
• Examples
| On this page… |
|---|
You can specify the reflectance characteristics of patch and surface objects and thereby affect the way they look when lights are applied to the scene. It is likely you will adjust these characteristics in combination to produce particular results.
Also see the material command for a convenient way to produce certain lighting effects.
You can control the amount of specular and diffuse reflection from the surface of an object by setting the SpecularStrength and DiffuseStrength properties. This picture illustrates various settings.

Ambient light is a directionless light that shines uniformly on all objects in the scene. Ambient light is visible only when there are light objects in the axes. There are two properties that control ambient light — AmbientLightColor is an axes property that sets the color, and AmbientStrength is a property of patch and surface objects that determines the intensity of the ambient light on the particular object.
This illustration shows three different ambient light colors at various intensities. The sphere is red and there is a white light object present.

The green [0 1 0] ambient light does not affect the scene because there is no red component in green light. However, the color defined by the RGB values [.5 0 1] does have a red component, so it contributes to the light on the sphere (but less than the white [1 1 1] ambient light).
The size of the specular highlight spot depends on the value of the patch and surface object's SpecularExponent property. Typical values for this property range from 1 to 500, with normal objects having values in the range 5 to 20.
This illustration shows a red sphere illuminated by a white light with three different values for the SpecularExponent property.

The color of the specularly reflected light can range from a combination of the color of the object and the color of the light source to the color of the light source only. The patch and surface SpecularColorReflectance property controls this color. This illustration shows a red sphere illuminated by a white light. The values of the SpecularColorReflectance property range from 0 (object and light color) to 1 (light color).

Back face lighting is useful for showing the difference between internal and external faces. These pictures of cut-away cylindrical surfaces illustrate the effects of back face lighting.

The default value for BackFaceLighting is reverselit. This setting reverses the direction of the vertex normals that face away from the camera, causing the interior surface to reflect light towards the camera. Setting BackFaceLighting to unlit disables lighting on faces with normals that point away from the camera.
You can also use BackFaceLighting to remove edge effects for closed objects. These effects occur when BackFaceLighting is set to reverselit and pixels along the edge of a closed object are lit as if their vertex normals faced the camera. This produces an improperly lit pixel because the pixel is visible but is really facing away from the camera.
To illustrate this effect, the next picture shows a blowup of the edge of a lit sphere. Setting BackFaceLighting to lit prevents the improper lighting of pixels.


This example creates a sphere and a cube to illustrate the effects of various properties on lighting. The variables vert and fac define the cube using the patch function.

sphere(36);
h = findobj('Type','surface');
set(h,'FaceLighting','phong',...
'FaceColor','interp',...
'EdgeColor',[.4 .4 .4],...
'BackFaceLighting','lit')
hold on
patch('faces',fac,'vertices',vert,'FaceColor','y');
light('Position',[1 3 2]);
light('Position',[-3 -1 3]);
material shiny
axis vis3d off
hold off
All faces of the cube have FaceColor set to yellow. The sphere function creates a spherical surface and the handle of this surface is obtained using findobj to search for the object whose Type property is surface. The light functions define two white (the default color) light objects located at infinity in the direction specified by the Position vectors. These vectors are defined in axes coordinates [x, y, z].
The patch uses flat FaceLighting (the default) to enhance the visibility of each side. The surface uses phong FaceLighting because it produces the smoothest interpolation of lighting effects. The material shiny command affects the reflectance properties of both the cube and sphere (although its effects are noticeable only on the sphere because of the cube's flat shading).
Because the sphere is closed, the BackFaceLighting property is changed from its default setting, which reverses the direction of vertex normals that face away from the camera, to normal lighting, which removes undesirable edge effects.

Examining the code in the lighting and material files can help you understand how various properties affect lighting.
![]() | Selecting a Lighting Method | Manipulating Transparency | ![]() |

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


