Transfer functions with delays in Matlab

I was wondering how to use delays in transfer functions. First I modeled the delay explicity with the e function. In this example I create the laplace variable s and use it in my transfer function Tf.

s = tf('s')
Tf = exp(-s) * G

In a forum I read about the function fieldnames() which lists all the argument names that a given matlab function takes.

fieldnames(tf)

ans = 

    'num'
    'den'
    'ioDelay'
    'Variable'
    'Ts'
    'InputDelay'
    'OutputDelay'
    'InputName'
    'OutputName'
    'InputGroup'
    'OutputGroup'
    'Name'
    'Notes'
    'UserData'

The list of the argument names of tf() contains ioDelay and that’s what can be used to delay a transfer function. Because matlab functions take a variable amount of arguments you cannot just type in

G = tf( 1, 1)

for the system 1 with a delay of one second as the second argument. The first argument is the numerator and the second the denumerator in this case. If you don’t use the standard order of arguments you have to list the arguments as matlab_function(‘fieldname1′, value1, ‘fieldname2′, value2, …).

Example:

G = tf( 1, 'ioDelay', 1)
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

Matlab commands for feedback controls

Here is a small matlab reference for feedback calculations or simulations:

  • roots: Find polynomial roots
  • poly: Convert roots to polynomial
  • conv: Convolution and polynomial multiplication
  • polyval: Evaluate polynomial
  • tf: Creation of transfer functions or conversion to transfer function
  • pzmap: Pole-zero map of LTI models
  • pole: Compute the poles of LTI models
  • zero: Computes the transmission zeros of LTI models
  • series: Series interconnection of the two LTI models
  • parallel: Parallel interconnection of two LTI models
  • feedback: Feedback connection of two LTI models
  • minreal: Minimal realization and pole-zero cancellation
  • step: Step response of LTI models
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

Matlab for C++ programmers

Today I went to Frankfurt to a seminar provided by MathWorks. It was about “Matlab for C++ programmers”. I learnt more about features that I didn’t know before like the Matlab engine. There’s more stuff that I’m going to tell you about later on but first some words about my trip.

When I came out of the train I rememberd my trip to a congress in Napoli two years ago. The train station in Frankfurt bear a resemblance to that one of Milano. Outside the first car I saw was an Italian. “Am I in Italy or in Frankfurt?” I asked myself. While I walked to the venue I took these pictures.

DSC00595.JPG DSC00594.JPG

Back to topic. At the seminar we were shown how easy data can be plotted with Matlab probably generated by a C/C++ application. With some sample codes the Matlab language was introduced. The following code plots a unit circle.

t = linspace(0, 2*pi, 200);
x = sin(t);
y = cos(t);
plot(x,y)

There is more stuff in the Matlab tool chain that was new to me:

  • The Matlab Engine is used to call Matlab software from C/C++ and Fortran.
  • Embedded Matlab is a subset of the Matlab language. Efficient code can be generated for embedded implementation with Embedded Matlab.
  • PolySpace products verify C, C++, and Ada code for embedded applications by detecting run-time errors before code is compiled and executed. This advanced verification technology uses formal methods not only to detect errors, but to prove mathematically that certain classes of run-time errors do not exist.
  • With the Matlab Compiler you are able to generate a standalone application from your Matlab code. This application can be ported to other computers without Matlab installed on it. You just need the Matlab Compiler Runtime (MCR) to execute the Matlab instructions. If MCR comes with the application the end user doesn’t need anything else of the Matlab tool chain. There’s no obstacle anymore to share your Matlab algorithms.
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

Sensor+Test 2008

DSC00097.JPG
I’ve just found a picture on my cell phone and I asked me what it shows. Then I’ve remembered the place where I took it. It was on the 15th International Trade Fair for Sensorics, Measuring and Testing Technologies on 6th May in Nürnberg.

The Mathworks gave a speech about “Live Data Analysis using Matlab”.

Amongst others I learnt how to grab signals from a sound card. The code looks like that:

ai=analoginput('winsound');
addChannel(ai,1);
start(ai)
[time,data]=getdata(ai);
plot(time, data);
stop(ai), delete(ai), clear ai

After the speech I asked the lecturer how to write my own toolbox. It’s quite simple. You only need to write your functions in m-files and design your graphical user interface (GUI) in GUIDE. That’s it.

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare