TECHNICAL UPDATES

Products Updates & information

New Control System Toolbox 7.0 delivers a powerful suite of capabilities

The Control System Toolbox provides tools for systematically analyzing, designing, and tuning linear control systems. You can specify a linear model of your system, plot its time and frequency responses to understand how the system behaves, tune the controller parameters using automated and interactive techniques, and verify performance requirements, such as rise time and gain/phase margins. Workflow-based graphical user interfaces (GUIs) guide you through each step of the analysis and design process.

In R2006a the integration of Control System Toolbox, Simulink Control Design and Simulink Response Optimization greatly simplifies and streamlines the task of compensator design.

Key Features

Automated tuning of compensators using PID, IMC and LQG design methods in SISO Tool. One click design.
Integrated tightly with Simulink Control Design for the design of multi-loop compensators in Simulink models
Integrated tightly with Simulink Response Optimization to allow optimization in SISO Tool
Major upgrade of Linear Time Invariant (LTI) objects and numerical engine for better performance and accuracy
   
 
Figure 1 - Automated tuning of compensators using Control & Estimation Tools Manager
   
Benefits for users
Integrated directly in the Simulink compensator design workflow
New simplified compensator design tools that reduces the need for deep control theory background.
   
   
 
Figure 2 - New compensator design tools
   
   
  To learn more about Control System Toolbox features:
http://www.mathworks.com/products/control/description1.html
 

  To understand Control System Toolbox capabilities through demos:
http://www.mathworks.com/products/control/demos.html
 
  DC Motor Control:
This demo shows two techniques for reducing the sensitivity of w to load variations (changes in the torque opposed by the motor load).
http://www.mathworks.com/products/control/demos.html?file=/products/demos/shipping/control/dcdemo.html
   
   
   
Technical Applications

New tool which allows you to share your MATLAB algorithms online

MATLAB Builder for .NET is an extension to the MATLAB Compiler. By using the .NET Builder, you can now package MATLAB functions so that .NET programmers can access them from any CLS (Common Language Specification) -compliant language. .NET Builder preserves the flexibility of MATLAB as it provides robust data conversion, indexing, and array formatting capabilities.

   
   
 
Figure 1: MATLAB Deployment options
   
Key Features
Converts your MATLAB algorithms into .NET or COM components via a graphical user interface
Creates .NET assemblies that can be called from C#, VB.NET, or any other Common Language Specification-compliant technology
Creates COM objects that can be called from Visual Basic, ASP, Microsoft Excel, or any other COM-compliant technology
Supports conversion between native .NET and COM data types and the MATLAB array data types, using data conversion classes
Enables unlimited free desktop and Web deployment of independent components
   
   
 
Figure 2: Using Builder for .NET: As Easy as 1-2-3
   
For more information about MATLAB Builder for .NET, please visit the following URL:
http://www.mathworks.com/products/netbuilder/
   

To learn more about MATLAB Builder for .NET through online demos, please visit the following URLs:

a. Deploying a COM Object over the Net

This demo will show how to run a MATLAB based application that calculates the price of a stock option, from the web by calling a COM object from an Active Server Page (ASP)

To view the demo, click here.

b. Deployment of a Soundcard Audio Analysis Application

This demo shows how you can use MathWorks products to deploy an application that acquires live, streaming data from a PC's soundcard. The data is collected using the Data Acquisition Toolbox, and then using MATLAB Builder for .NET to generate a component, which is integrated with a Microsoft Visual Basic .NET project.

To view the demo, click here.

 

Using MATLAB to Compute Call Option Sensitivity Measures

MATLAB and Financial Toolbox offer a single, integrated environment for mathematical and statistical analysis of financial data. Using the Financial Toolbox you can optimize portfolios, estimate risk, analyze interest rate levels, price equity derivatives, and handle financial time series.

In this example, we will compute and plot the call option sensitivity measure, gamma, as a function of price and time for a portfolio of 10 Black-Scholes options. The plot shows a three-dimensional surface. For each point on the surface, the height (z-value) represents the sum of the gammas for each option in the portfolio weighted by the amount of each option. The x-axis represents changing price, and the y-axis represents time. The plot adds a fourth dimension by showing delta as surface color. This has applications in hedging.

Step 1: Set Up a Portfolio of Options on a Single Stock

% Range of stock prices for sensitivity analysis
range = 20:90;
plen = length(range);

% Basic information for each option
exprice = [75 70 50 55 75 50 40 75 60 35];
rate = 0.1*ones(10,1);
time = [36 36 36 27 18 18 18 9 9 9];
sigma = 0.35*ones(10,1);

% Portfolio weights
numopt = 1000*[4 8 3 5 5.5 2 4.8 3 4.8 2.5];

zval = zeros(36, plen);
color = zeros(36, plen);

Step 2: Loop Over Each Option in the Portfolio to Calculate Gamma and Delta

for i = 1:10

pad = ones(time(i),plen);
newr = range(ones(time(i),1),:);

t = (1:time(i))';
newt = t(:,ones(plen,1));

% Calculate gammas
zval(36-time(i)+1:36,:) = zval(36-time(i)+1:36,:) ...
+ numopt(i) * blsgamma(newr, exprice(i)*pad, ...
rate(i)*pad, newt/36, sigma(i)*pad);

% Calculate deltas
color(36-time(i)+1:36,:) = color(36-time(i)+1:36,:) ...
+ numopt(i) * blsdelta(newr, exprice(i)*pad, ...
rate(i)*pad, newt/36, sigma(i)*pad);

end

Step 3: Plot Sensitivities of a Portfolio of Options

  • Height is gamma (second derivative of option price with respect to stock price)
  • Color is delta (first derivative of option price with respect to stock price)
     
    figure('NumberTitle', 'off', ...
      'Name', 'Call Option Portfolio Sensitivity');
  • mesh(range, 1:36, zval, color);
    view(60,60);
    set(gca, 'xdir','reverse', 'tag', 'mesh_axes_3');
    axis([20 90 0 36 -inf inf]);

    title('Call Option Portfolio Sensitivity');
    xlabel('Stock Price ($)');
    ylabel('Time (months)');
    zlabel('Gamma');
    set(gca, 'box', 'on');
    colorbar('horiz')

   
   

For more information about Financial Toolbox, please visit the following URL:
http://www.mathworks.com/products/finance/

For more information about other related application demos, please visit the following URL:
http://www.mathworks.com/products/finance/demos.html

   
 
 
Tips and Techniques

Ways to optimize your memory space and achieve faster code performance

Is your MATLAB program running slow? Do you have multiple iterative loops (for and while loops) in your program that handle matrices and arrays?

for and while loops that incrementally increase the size of a data structure each time through the loop can adversely affect performance and memory use. Repeatedly resizing arrays often requires that MATLAB spend extra time looking for larger contiguous blocks of memory and then moving the array into those blocks. You can often improve on code execution time by preallocating the maximum amount of space that would be required for the array ahead of time.

How to perform array preallocation?

Consider the following MATLAB code. The code below creates scalar variable a and b. Then gradually increases the size of a and b in a for loop instead of preallocating the required amount of memory at the start.

% Create variables a & b
a(1) = 1;
b(1) = 0;

% Using tic & toc to time the time lapsed in the for loop
tic;
% Increase the size of a & b using a for loop

for k = 2:8000
  a(k) = 0.99803 * a(k-1) - 0.06279 * b(k-1);
b(k) = 0.06279 * a(k-1) + 0.99803 * b(k-1);
end

toc;

The code above takes average 0.23 seconds.

Change the first 2 lines to preallocate a 1-by-8000 block of memory for a and b initialized to zero. This time there is no need to repeatedly reallocate memory and move data as more values are assigned to a and b in the loop.

% Preallocation
a = zeros(1,8000);
b = zeros(1,8000);

a(1) = 1;
b(1) = 0;

% Using tic & toc to time the time lapsed in the for loop
tic;
% Increase the size of a & b using a for loop

for k = 2:8000
  a(k) = 0.99803 * a(k-1) - 0.06279 * b(k-1);
b(k) = 0.06279 * a(k-1) + 0.99803 * b(k-1);
end

toc;

With this modification, the code takes only 0.0013 seconds (over hundred times faster). Preallocation is often easy to do. In this case it was only necessary to determine the right preallocation size and add two lines.

What if the final array size can vary?

One approach is to use the upper bound on the array size and cut the excess after the loop:

% Preallocation
a = zeros(1,10000);
count = 0;

tic;

for k = 1:10000
  v = exp(rand(1)*rand(1));
 
  % Conditionally add to array
  if v > 0.5
    count = count + 1;
    a(count) = v;
  end
end

% Trim the result
a = a(1:count);
toc;

 

The average run time of the code above is 0.15 seconds without array preallocation and 0.05 seconds with array preallocation.

For detail information on Array Preallocation, please kindly refer to the URL below:
http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f8-793781.html

 

 
 EVENTS & TRAINING
 
 Training
 

Hands-on workshop @S$150* only

Attend Activemedia new series of MATLAB hands-on workshops at SGD$150 per course from the 4th participant onwards*. This introductory offer is valid in Singapore only. *Terms & conditions apply.
For more details, call Activemedia at 6742-8173

 

Applying Statistical Methods using MATLAB

This two-day course provides an introduction to statistical tools in MATLAB and the Statistics Toolbox. Topics include data file input and output, handling large and incommensurate data sets, computing descriptive statistics, statistical plotting and visualization, fitting distributions to data, bivariate and multivariate regression, random number generators, simulation, and basic inferential methods. Examples and exercises cover a cross-section of application areas in science, engineering, and finance.

 

Applying Finite State Machine Modeling with STATEFLOW

This one-day workshop provides an understanding of how to use Stateflow to model finite-state machine theory and supervisory logic. The course discusses how to interact with Simulink, and graphically build flow diagrams and functions. Code generation and sending data out of Stateflow are briefly mentioned in this course as well.

 

SIMULINK S-Functions for System Algorithm Modeling

This is a hands-on one-day workshop that provides an extensive coverage on Simulink S-functions, with examples and exercises that comprehensively employ the features to custom system and algorithm development. The course emphasizes S-function concepts and methodologies. The course targets intermediate and experienced users with exposure to Simulink and MATLAB.

 

Implementing FPGA for Signal Processing using SIMULINK

This is a one-day hands-on workshop to learn how to develop signal processing algorithm for FPGA device using system level tools such as Simuink. The basics of using the Signal Processing Blockset in SIMULINK to analyze and design a signal processing system will also be covered.

 
Visit www.activemedia.com.sg or Contact us at:

Singapore:
(65) 6742 8173
enquiry@activemedia.com.sg

Malaysia:
(60) 3 7880 8522
enquiry@activemedia.com.my

Thailand:
(66) 2 612 9390-1
info@activemedia.in.th

 
 
 
Customer Applications
 
 User Stories
 
Clarkson University Brings Consistency to Engineering Curriculum by Standardizing on MathWorks Tools
 
Challenge To unify the freshman curriculum across all engineering departments
Solution Standardize on MathWorks tools to create multidisciplinary labs
Results
  • University reduces software costs by thousands of dollars.
  • Unified curriculum helps students choose appropriate discipline.
  • Students save on software costs.
 

Aspiring engineers are often uncertain which discipline to pursue when they begin their undergraduate studies. Universities strive to make their students' decisions easier by offering challenging but consistent courses that address both theory and practice.

Today, all departments within the Wallace H. Coulter School of Engineering at Clarkson University use MathWorks tools as the standard software environment in a freshman course that introduces and applies engineering concepts in a multidisciplinary lab setting.

"Standardizing on MathWorks tools and instituting a common freshman course has enabled us to create a consistent experience for all students across the school of engineering," says Jim Carroll, associate professor, Department of Electrical and Computer Engineering at Clarkson University.


Students using MathWorks tools
with TI C2000 processors.
 
Challenge
 

Clarkson University sought to unify the freshman curriculum across their engineering departments by standardizing on software that students would use throughout their studies and, eventually, in industry.

The software tools selected would also need to engage students in a way that helps them determine which engineering discipline to pursue.

In the past, individual faculty members used various software tools to teach ES100: Introduction to Engineering Use of the Computer.

"Because professors recommended their own software, it was difficult to ensure that engineering students would acquire uniform knowledge of a particular tool or language," says Carroll.

Supporting many software products also increased costs for the university in terms of maintenance, training, and system resources. Because the software was also required for out-of-class homework assignments, students had to purchase licenses for each instructor-selected software package.

"Knowledge of MathWorks tools is widely sought after by those engineering faculty teaching upper-level courses and performing research. After speaking to our recent graduates, it became even clearer how widely adopted MathWorks tools are in industry."

Jim Carroll
Clarkson University
 
Solution
 

By standardizing on MathWorks tools, Clarkson University has prepared first-year students-regardless of engineering discipline-for upper-level classes that require MATLAB, Simulink, and related products.

"By standardizing on MathWorks tools, all of our freshman engineering students are exposed to the same topics and obtain the knowledge they need to function at a high level," says Carroll.

Although MathWorks tools are used across all of the engineering disciplines, they are most prevalent through the electrical engineering courses, beginning with the ES100 prerequisite.

In one of Carroll's ES100 computer lab lectures, his students solve a set of equations that determine the maximum power transfer to a resistive load. They begin by writing a script using MATLAB, apply MATLAB functions, such as max(), and perform indexing to determine the resistive load.

"If my students had to numerically analyze the possible combinations by hand, they would get pretty frustrated," explains Carroll. "MATLAB connects the students to the topic and lets them explore various possibilities quickly."

In addition to the lecture component, an integrated lab experience enables students to use MATLAB and the Data Acquisition Toolbox with engineering equipment and instruments. In the lab, students learn how to design, build, test, and document simple circuits, such as a keyless entry system.

"By using MathWorks tools in our lab setting, students can determine whether they prefer the more hands-on aspects of engineering or are more interested in the underlying analysis and design," says Carroll.

In EE251: Dynamical Systems, sophomores apply class concepts using MATLAB and Simulink to model electrical, mechanical, thermal, and fluid systems.

In the dynamical systems course, Carroll typically assigns a fun class project such as the "Electric Dukes of Hazzard," in which students "build" an electric car.

In EE321: Systems and Signal Processing, juniors use the Control System and Signal Processing toolboxes to explore conceptual, analytical, and computational issues in communications, signals processing, and controls.

In EE401: Digital Signal Processing, seniors use Simulink with the Signal Processing Blockset (formerly the DSP Blockset) to develop DSP applications. They also use Real-Time Workshop to generate embedded code from Simulink models. They then implement the code in real time using the Embedded Target for TI C2000 DSP.

Awarded a three-year Course, Curriculum, and Laboratory Improvement grant from the National Science Foundation, Clarkson's Wallace H. Coulter School of Engineering will further enhance its multidisciplinary lab project courses using MathWorks tools.

 
Results
 
University reduces software costs by thousands of dollars. Clarkson University saves more than $10,000 in software costs per year by using a common set of software tools.
Unified curriculum helps students choose appropriate discipline. By choosing a common set of tools and integrating a lab component, Clarkson University provides a common freshman learning experience that enables students to pursue an engineering discipline of their choice.
Students save on software costs. "Now, students can transfer between engineering programs without learning or purchasing new software tools," says Carroll.
 
Products Used