Some Random Simulink and Real Time Workshop tips

Display precision

The format command is what you want. Type help format to learn how to see more digits displayed (or less).

Mouse action

How do you select and manipulate a group of blocks on a simulink diagram?

It all seems simple once you figure it out, but it has driven me crazy over and over, so here it is explained clearly once and for all.

First off, it does not seem to matter whether you use the left or right mouse button.

Making the selection is the easy part, just use the left mouse button, click at one point, then while holding the mouse button down, move the mouse. A rectangle will be generated and all blocks within the rectangle will be selected. If you don't like the selection, just click on some blank part of the diagram and it goes away and you try again.

The trick is doing something useful once a set of blocks have been selected. What I was doing wrong for so long, was clicking near a set of selected blocks, you actually have to click on one (any one!) of the selected blocks, then drag to move the whole collection. Easy and wonderful when you learn that close does not count.

If you make a selection, then hold the CTRL keyboard key down while clicking on a block with the mouse, you move a copy of the selected blocks and the originals are left where they were. Holding down the shift key does not seem to do anything new and interesting, it just lets you move blocks the same as if you had not held it down.

You can also make a selection, then hit the DELETE key to get rid of a bunch of blocks, and you can do cut and paste using the EDIT pulldown menu.

Block action

So, you have a block on your diagram, but data flow is right to left rather than left to right and you want to flip the block so it's inputs and outputs change sides. Use Control-I to flip, Control-R to rotate.

Exporting arrays

Once an array is in the workspace, there are several ways to get it to disk. You can save it as a .mat file (only good if you only ever want to pull it back into matlab. You can save it as a CSV or XML file. You can even save it as a plain ascii file. The command to use is:
dlmwrite('outfile',transpose(array),'delimiter',' ','precision',8)
Without the transpose, an array gets written as one record with all the values separated by the delimiter. With the transpose, you might as well just leave out the delimiter. Precision can also be specified (so to speak), by giving a C-language style format like "%.8f". A format like "%.8e" might be a better choice.
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org