Matlab Recipes From beginner to pro, Matlab Recipes caters for all

Pi to many decimal places 0

Writing Formatted Data

The sprintf/fprintf family of functions are more powerful than you know. Even if you think you know what they can do, I bet some functionality has been added since you initially learnt about them. If you have a c-code background and have never read the MATLAB documentation, you may be missing out on some very powerful features like vectorised mode or dynamic precision. This article takes you from beginner to some of the more obscure/advanced features, but features which I think you will find very useful given the correct application.

running-wide 0

How to Force a Simulink Block to Run with the Fundamental Sample Time

Hello all, it's been a while, but I'm still here, just been very busy. I'm still working with MATLAB & Simulink, but have also been doing lots of C++ & C# as well. Here's a quick post, to share a technique I worked out, which some may find useful. Whilst working with a multi-rate Simulink model, I wanted a block to run at the fundamental sample rate of the model, i.e. the one you specify in the Solver Settings. What felt like a simple request, proved to be quite tricky.

MATLAB Unit Testing 12

How to Write Error Free MATLAB Code

When you write some MATLAB code, how do you know it is correct and error free? If you edit some existing code, how do you know whether you have broken some pre-existing functionality? The simple answer is TEST it. But nowadays, it's not enough just to try a few values from the command line. With the advent of R2013a, MATLAB now has an automated test suite baked right in to the basic install. Let's explore it using Test Driven Development (TDD)

Frequent MATLAB bugs 7

My Top 5 Most Painful MATLAB Bugs

What I'd like to talk about here are the worst kind of bugs; ones where your code appears to work, or even does work with your test data but will fall over in the field or worse still just gives you slightly the wrong answer. I'll present to you my top 5 most painful MATLAB bugs, which have have all tripped me up over the years, and give you some actionable advice on how to methodically avoid them. They are presented in increasing order of pain, which is roughly equal to frequency*cost_of_bug.

Yair Altman 0

Advanced MATLAB Training (UK)

A new post from Yair Altman at Undocumented Matlab announces he is coming to London to run some of his training courses. The upcoming event is in London in March 10-14.

Write MATLAB professional functions

How to Write a MATLAB Function Like a Pro

This article takes you through writing a MATLAB function from the required bare minimum to a fully fledged professional looking function with help text, like a pro would write. It demonstrates how the H1 comment you write becomes integrated into the MATLAB IDE and how comments like See Also automatically produce hyper-linked help pages.

MATLAB switch case 3

MATLAB switch case

A quick post on how I use MATLAB's switch case statements. I give an example of dangerous use and provide a simple fix.