0% found this document useful (0 votes)
39 views

Computing For Engineers PDF

Uploaded by

RUBEN BIZURU
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Computing For Engineers PDF

Uploaded by

RUBEN BIZURU
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Uganda Christian University

Computing for Engineers

Ronald Ssejjuuko
Department of computing & IT

week 1
Our Guiding Principles

“The purpose of computing is insight, not numbers”


Richard Hamming

“I hear and I forget,


I see and I remember,
I do and I understand.”
Confucious
This course is an introduction to MATLAB, a powerful
programming language and development environment for
engineers and scientists.

MATLAB ® is a registered trademark of The Mathworks


Inc., http://www.mathworks.com

MATLAB & Simulink Student Version


Main Features of MATLAB

• Easy and efficient programming in a high-level language, with


an interactive interface for rapid development.

• Vectorized computations for efficient programming, and


automatic memory allocation.

• Built-in support for state-of-the-art numerical computing


methods.

• Has variety of modern data structures and data types,


including complex numbers.

• High-quality graphics and visualization.


• Symbolic math toolbox for algebraic and calculus operations,
and solutions of differential equations.

• Simulation capability with SIMULINK.

• Portable program files across platforms.

• Large number of add-on toolboxes for applications and


simulations.

• Huge database of user-contributed files & toolboxes, including


a large number of available tutorials & demos.

• Allows extensions based on other languages, such as C/C++,


supports Java and object-oriented programming.
MATLAB Toolbox Application Areas

• Parallel Computing
• Math, Statistics, and Optimization
• Control System Design and Analysis
• Signal Processing and Communications
• Image Processing and Computer Vision
• Test and Measurement, Data Acquisition
• Computational Finance, Datafeeds
• Computational Biology
• Code Generation and Application Deployment
• Database Connectivity
SIMULINK Applications

• Fixed-Point and Event-Based Modeling


• Physical Modeling (mechanics, driveline, hydraulics, RF,
electronics, power systems, biology)
• Control Systems (design, optimization, aerospace)
• Signal & Image Processing and Computer Vision
• Communication Systems (digital, analog, wireless)
• Code Generation (for embedded systems, DSP chips and
FPGAs)
• more
Web Resources
• Getting Started with MATLAB (HTML)
• Getting Started with MATLAB (PDF)
• MATLAB Examples
• MATLAB Online Tutorials and Videos
• MATLAB Interactive Tutorials
• MATLAB Toolbox Reference Manuals
• MATLAB Interactive CD
• Newsletters
• MATLAB User Community
• Other MATLAB Online Resources
• comp.soft-sys.matlab newsgroup
• Octave – a free look-alike version of MATLAB
• FreeMat – another free look-alike version
• NIST – Digital Library of Mathematical Functions
• NIST – Physical Constants
Weekly Topics

Week 1 - Basics – variables, arrays, matrices, plotting (ch. 2 & 3)


Week 2 - Basics – operators, functions, strings, cells (ch. 2,3,11)
Week 3 - Matrices (ch. 4)
Week 4 - Plotting – 2D and 3D plots (ch. 5) Test 1
Week 5 - User-defined functions (ch. 6)
Week 6 - Input-output formatting – fprintf, fscanf (ch. 7) –
Week 7 - Relational & logical operators, if, switch statements (ch. 8)
Week 8 - For-loops, while-loops (ch. 9)
Week 9 - Review for weeks 5-8 Test 2
Week 10 - Matrix algebra – solving linear equations (ch. 10) –
Week 11 - Numerical methods I (ch. 13)
Week 12 - Numerical methods II (ch. 13)
Week 13 - Strings, structures, cell arrays, symbolic math (ch. 11,12)
Week 14 – Exam 3
References: H. Moore, MATLAB for Engineers, 4/e, Prentice Hall, 2014
G. Recktenwald, Numerical Methods with MATLAB, Prentice Hall, 2000
A. Gilat, MATLAB, An Introduction with Applications, 4/e, Wiley, 2011
MATLAB Basics

1. MATLAB desktop
2. MATLAB editor
3. Getting help
week 1
4. Variables, built-in constants, keywords
5. Numbers and formats
6. Arrays and matrices
7. Operators and expressions
8. Functions – built-in and user-defined
9. Basic plotting week 2
10. Function maxima and minima
11. Strings, cell arrays, fprintf

These should be enough to get you started. We will explore


them further, as well as other topics, in the rest of the course.
1. MATLAB Desktop
choose move, minimize,
desktop layout command window, navigate to resize, close
enter commands desired folder
at prompt
set search
path

Help

to array editor
doubleclick
to edit M-file
workspace
window

current
folder

view details command


about selected history
file
2. MATLAB Editor

switch to
command window
3. Getting Help
Several ways of getting help:

1) help menu item on MATLAB desktop opens up searchable


help browser window

2) from the following commands: comments begin with %

>> helpdesk % open help browser


>> help topic % e.g., help log10
>> doc topic % e.g., doc plot
>> help % get list of all help topics
>> help dir % get help on entire directory
>> help syntax % get help on MATLAB syntax
>> help / % operators & special characters
>> docsearch text % search HTML browser for ‘text’
>> lookfor topic % e.g., lookfor acos
4. Variables, Constants, Keywords

Variables require no special declarations of type or


storage. Examples:

>> x = 3; % simple scalar


>> y = [4, 5, 6]; % row vector of length 3
>> z = [4; 5; 6]; % column vector of length 3
>> A = [1,2,3; 4,5,6]; % 2x3 matrix
>> s = 'abcd efg'; % string
>> C = {'abc', 'defg', '123-456'}; % 1x3 cell array

the functions class and size


math notation tell you the type and dimensions
of the defined object, e.g.,
>> class(C)
>> size(C)
>> x = 3
x =
3

>> y = [4, 5, 6]
y =
4 5 6

>> z = [4; 5; 6] % note, z = y'


z =
4
5
6

>> A = [1 2 3; 4 5 6]
A =
1 2 3
4 5 6
What are your variables? How to clear them?
Use workspace window, or the commands:
who, whos, clear, clc, close

>> who
Your variables are:
A y z

>> whos
Name Size Bytes Class Attributes
A 2x3 48 double
y 1x3 24 double
z 3x1 24 double

>> clear all % clear all variables from memory


>> clc % clear command window
>> close all % close all open figures
Operating system commands:

>> path % display search path


>> pathtool % modify search path
>> addpath dir % add directory to path

>> cd dir % change directory


>> pwd % print working directory

>> dir % list all files in current dir


>> what % list MATLAB files only
>> which file % display location of file

>> edit file % invoke MATLAB editor

>> quit % quit MATLAB


>> exit % quit MATLAB
Special built-in math constants that should not
(though they can) be re-defined as variables:

eps % machine epsilon - floating-point accuracy


i,j % imaginary unit, i.e., sqrt(-1)
Inf,inf % infinity
intmax % largest value of specified integer type
intmin % smallest value of specified integer type
NaN,nan % not-a-number, e.g., 0/0, inf/inf
pi % pi
realmax % largest positive floating-point number
realmin % smallest positive floating-point number

Note: i,j are commonly used for array and matrix indices. If you’re
dealing with complex-valued data, avoid redefining both i,j.
Values of special constants:
>> eps % equal to 2^(-52)
ans =
2.2204e-016 % MATLAB’s floating-point accuracy
% i.e., 2.2204 * 10^(-16)
>> intmax % 2^(31)-1 for 32-bit integers
ans =
2147483647

>> intmin % equal to -2^(31)


ans =
-2147483648

>> realmax % equal to (2-eps)*2^(1023)


ans =
1.7977e+308 % i.e., 1.7977 * 10^(308)

>> realmin % 2^(-1022) = 2.2251 * 10^(-308)


ans =
2.2251e-308
Special keywords that cannot be used
as variable names:

>> iskeyword

ans =
'break' 'function'
'case' 'global'
'catch' 'if'
'classdef' 'otherwise'
'continue' 'parfor'
'else' 'persistent'
'elseif' 'return'
'end' 'switch'
'for' 'try'
'while'

'true' , 'false'
5. Numbers and Formats

MATLAB by default uses double-precision (64-bit)


floating-point numbers following the IEEE floating-point
standard. You may find more information on this
standard in:
Representation of Floating-Point Numbers
C. Moler, "Floating Points," MATLAB News and Notes,
Fall, 1996 (PDF file)

x = (-1)^s * (1+f) * 2^(e-1023) 0 <= f < 1


f_min = eps = 2^(-52)
1 bit 52 bits 11 bits
sign mantissa exponent machine epsilon
1 <= e <= 2046, e=0, e=2047
MATLAB can also use single-precision (32-bit) floating
point numbers if so desired.
There are also several integer data types that are useful
in certain applications, such as image processing or
programming DSP chips. The integer data types have 8,
16, 32, or 64 bits and are signed or unsigned:
int8, int16, int32, int64
uint8, uint16, uint32, uint64

For more information do:


>> help datatypes
>> help class % determine datatype
Complex Numbers
By default, MATLAB treats all numbers and expressions as
complex (even if they are real).

No special declarations are needed to handle complex-number


operations. Examples:

>> z = 3+4i; % or, 3+4j, 3+4*i, 3+4*j


>> x = real(z); % real part of z
>> y = imag(z); % inaginary part of z
>> R = abs(z); % absolute value of z
>> theta = angle(z); % phase angle of z in radians
>> w = conj(z); % complex conjugate, w=3-4i
>> isreal(z); % test if z is real or complex

cartesian & polar forms math notation: q = Arg(z)


equivalent definitions:
>> z = 3+4j
z = z = 3+4*j
3.0000 + 4.0000i z = 3+4i
z = 3+4*i
>> x = real(z) z = complex(3,4)
x =
3
>> y = imag(z)
y =
4
>> R = abs(z)
R =
5
>> theta = angle(z) % in radians
theta =
0.9273

>> abs(z - R*exp(j*theta)) + abs(z-x-j*y) % test


ans =
6.2804e-016
Display Formats
>> format % default - 4 decimal places
>> format short % same as the default
>> format long % 15 decimal places
>> format short e % 4 decimal – exponential format
>> format short g % 4 decimals – exponential or fixed
>> format long e % 15 decimals - exponential
>> format long g % exponential or fixed
>> format shorteng % 4 decimals, engineering
>> format longeng % 15 decimals, engineering
>> format hex % hexadecimal
>> format rat % rational approximation
>> format compact % conserve vertical spacing
>> format loose % default vertical spacing

>> vpa(x,digits) % variable-precision-arithmetic

These affect only the display format – internally all


computations are done with full (double) precision
Example - displayed value of 10*pi in different formats:

31.4159 % format, or format short


31.415926535897931 % format long
3.1416e+001 % format short e
31.416 % format short g
3.141592653589793e+001 % format long e
31.4159265358979 % format long g
31.4159e+000 % format shorteng
31.4159265358979e+000 % format longeng

>> vpa(10*pi) % symbolic toolbox


ans =
31.415926535897932384626433832795

>> vpa(10*pi,20) % specify number of digits


ans =
31.415926535897932385

>> help format


>> help vpa
>> help digits
input/output functions: disp, input

>> x = 10; disp('the value of x is:'); disp(x);


the value of x is:
10

>> x = input('enter x: ') % numerical input


enter x: 100 % 100 entered by user
x =
100 prompt string in single quotes

>> y = input('enter string: ', 's'); % string input


enter string: abcd efg
>> y = input('enter string: ')
enter string: 'abcd efg' string entered with no quotes
y = string entered in quotes
abcd efg
>> help disp
>> help fprintf >> help input
>> help sprintf >> help menu
6. Arrays and Matrices

arrays and matrices are the most


important data objects in MATLAB

We discuss briefly:
a) row and column vectors
b) transposition operator, '
c) colon operator, :
d) equally-spaced elements, linspace
e) accessing array elements
f) dynamic allocation & de-allocation
g) pre-allocation
The key to efficient MATLAB programming
can be summarized in three words:

vectorize, vectorize, vectorize


and avoid all loops

Compare the two alternative computations:

x = [2,-3,4,1,5,8]; x = [2,-3,4,1,5,8];
y = zeros(size(x)); y = x.^2;
for n = 1:length(x)
y(n) = x(n)^2;
element-wise exponentiation .^
end
ordinary exponentiation ^

answer: y = [4,9,16,1,25,64]
>> x = [0 1 2 3 4 5] % row vector
x =
0 1 2 3 4 5

>> x = 0:5 % row vector


x =
0 1 2 3 4 5

>> x = [0 1 2 3 4 5]' % column vector, (0:5)'


x =
0
1 the prime operator, ', or transpose, turns row
2 vectors into column vectors, and vice versa
3
4 caveat: ' is actually conjugate transpose,
5 use dot-prime, .' , for transpose w/o conjugation
>> z = [i; 1+2i; 1-i] % column vector
z =
0 + 1.0000i
1.0000 + 2.0000i
1.0000 - 1.0000i

>> z.' % transpose without conjugation


ans =
0 + 1.0000i 1.0000 + 2.0000i 1.0000 - 1.0000i

>> z' % transpose with conjugation


ans =
0 - 1.0000i 1.0000 - 2.0000i 1.0000 + 1.0000i

>> (z.')' % same as (z').' , or, conj(z)


ans =
0 - 1.0000i
1.0000 - 2.0000i
1.0000 + 1.0000i
about linspace:

x = linspace(a,b,N+1);

is equivalent to:

x = a : (b-a)/N : b;

i.e., N+1 equally-spaced points in the interval [a,b]


or, dividing [a,b] into N equal sub-intervals

step
increment

>> x = 0 : 0.2 : 1 % in general, x = a:s:b


>> x = linspace(0,1,6) % see also logspace
x =
0 0.2000 0.4000 0.6000 0.8000 1.0000

6 points, 5 subintervals
step increment
>> x = 0 : 0.3 : 1
x = x = a : s : b;
0 0.3 0.6 0.9
the number of subintervals
within [a,b] is obtained by
>> x = 0 : 0.4 : 1 rounding (b-a)/s, down
x = to the nearest integer,
0 0.4 0.8 N = floor((b-a)/s);
length(x) is equal to N+1
>> x = 0 : 0.7 : 1 x(n) = a + s*(n-1),
x = n = 1,2,...,N+1
0 0.7

% before rounding, (b-a)/s was in the three cases:


% 1/0.3 = 3.3333, 1/0.4 = 2.5, 1/0.7 = 1.4286
Note: MATLAB array indices always start with 1
and may not be 0 or negative
exception:
logical indexing,
>> x = [ 2, 5, -6, 10, 3, 4 ]; discussed later

x(1), x(2), x(3), x(4), x(5), x(6)

Other languages, such as C/C++ and Fortran, allow


indices to start at 0. For example, the same array
would be declared/defined in C as follows:

double x[6] = { 2, 5, -6, 10, 3, 4 };

x[0], x[1], x[2], x[3], x[4], x[5]

rule of thumb: M = C + 1
accessing array entries:
>> x = [2, 5, -6, 10, 3, 4]
x =
2 5 -6 10 3 4

>> length(x) % length of x, see also size(x)


ans =
6

>> x(1) % first entry


ans =
2

>> x(3) % third entry


ans =
-6

>> x(end) % last entry – need not know length


ans =
4
accessing array entries:

>> x(end-3:end) % x = [2, 5, -6, 10, 3, 4]


ans =
-6 10 3 4 % last four

>> x(3:5) % list third-to-fifth entries


ans =
-6 10 3

>> x(1:3:end) % every third entry


ans =
2 10

>> x(1:2:end) % every second entry


ans =
2 -6 3
accessing array entries:

>> x = [2, 5, -6, 10, 3, 4];

>> x(end:-1:1) % list backwards, same as fliplr(x)


ans =
4 3 10 -6 5 2

>> x([3,1,5]) % list [x(3),x(1),x(5)]


ans =
-6 2 3

>> x(end+3) = 8
x =
2 5 -6 10 3 4 0 0 8

automatic memory re-allocation


automatic memory allocation and de-allocation:

>> clear x

>> x(3) = -6
x =
0 0 -6

>> x(6) = 4
x =
0 0 -6 0 0 4

>> x(end) = [] % delete last entry


x =
0 0 -6 0 0

>> x = [2, 5, -6, 10, 3, 4];


>> x(3)=[] % delete third entry
x =
2 5 10 3 4
pre-allocation

>> clear x
>> x = zeros(1,6) % 1x6 array of zeros
x =
0 0 0 0 0 0

>> x = zeros(6,1) % 6x1 array of zeros


x =
0
0 Pre-allocation is useful for very large arrays, e.g.,
0 length > 10^4, for example, in dealing with
0 audio or image files, or finite-element methods.
0
0 See, for example, the program echoes.m, which
reads an audio file and adds reverberation effects
to it, as described in echoes.pdf, and discussed
also in week-2 lectures.
>> help zeros
>> help ones
illustrating dynamic allocation & pre-allocation

clear x;
for k=[3,7,10] % k runs successively through
x(k) = 3 + 0.1*k; % the values of [3,7,10]
disp(x); % diplay current vector x
end

0.0 0.0 3.3


0.0 0.0 3.3 0.0 0.0 0.0 3.7
0.0 0.0 3.3 0.0 0.0 0.0 3.7 0.0 0.0 4.0

x = zeros(1,10); % pre-allocate x to length 10


for k=[3,7,10]
x(k) = 3 + 0.1*k;
disp(x);
end

0.0 0.0 3.3 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 3.3 0.0 0.0 0.0 3.7 0.0 0.0 0.0
0.0 0.0 3.3 0.0 0.0 0.0 3.7 0.0 0.0 4.0
Example: Octave Frequency Scales

• Tasks:

• calculate and plot the 88 frequencies of a standard 88-key piano


keyboard

• introduce the concept of octave frequency scales

• generate and print the major notes (do, re, mi, fa, sol, la, si, do) of
the middle (4th) octave, and play them forward & backward on the
PC’s soundcard (need earphones in the DSV lab)

Complete MATLAB program is in the M-file, octaves.m.


standard 88-key piano keyboard

1 2 3 4 5 6 7

A0 A1 A2 A3 C A4 A5 A6 A7
27.5 Hz 55 Hz 110 Hz 220 Hz 440 Hz 880 Hz 1760 Hz 3520 Hz
20 21 22 23 24 25 26 27

f
octaves = log2 ( ) f0
.
f = f0 2
octaves

generate tone and


y(t) = sin(2  f t ) send it to MATLAB’s
sound() function
Running the program, octaves.m, in command window:

>> octaves; % run the program

>> close all; % close figure windows

>> publish('octaves', 'html'); % export to HTML

Publishing your programs to HTML is a good way to print and submit


homework problems. However, you must re-save it as a single file web
archive (i.e., MHT file) that incorporates all the generated graphs (for
Firefox you must install the Mozilla-Archive-Format add-on).

You can also “publish” your programs directly to PDF or DOC formats.
key, k=0 key, k=87

1 2 3 4 5 6 7

A0 A1 A2 A3 C A4 A5 A6 A7
27.5 Hz 55 Hz 110 Hz 220 Hz 440 Hz 880 Hz 1760 Hz 3520 Hz
20 21 22 23 24 25 26 27

f
octaves = log2 ( ) f0 f = f0 . 2
octaves

keys indexed by f0 = 27.5;


k = [0, 1, 2, …, 87] k = 0:87; MATLAB code
f = f0 * 2.^(k/12); from file
successive keys are figure; plot(k,f); octaves.m
separated by
1/12 of an octave figure; plot(k, log2(f/f0));
plain vanilla plot with system default
choices for axes limits, tick marks,
and no labels – see next page for a better plot

5000

4000

3000

2000

1000

0
0 20 40 60 80 100
frequ encies on a pia no keyboa r d
3960 a ll 88 keys
3520 'A' k eys on ly
3080
2640
f (H z)

2200
1760
1320
880
440
0
0 12 24 36 48 60 72 84
k , pia no k ey
ka = 0:12:87; red color, open circles
fa = f(ka+1);
figure; plot(k,f, ka,fa,'ro'); plot fa vs. ka,
i.e., the ‘A’ keys
% ka = [0, 12, 24, 36, 48, 60, 72, 84]
% fa = [27.5, 55, 110, 220, 440, 880, 1760, 3520]

Next, we add commands to annotate the graph


with axis labels, axis limits, tick marks, grid, title,
and legends

>> help plot

note: we defined fa as a subset of f,


but we could have defined it directly as,
fa = f0 * 2.^(ka/12);
ka = 0:12:87; red color, open circles
fa = f(ka+1);
figure; plot(k,f, ka,fa,'ro'); plot fa vs. ka,
i.e., the ‘A’ keys
% ka = [0, 12, 24, 36, 48, 60, 72, 84]
% fa = [27.5, 55, 110, 220, 440, 880, 1760, 3520]

xlim([0,87]); set(gca,'xtick', 0:12:87); set axis limits


ylim([0,4200]); set(gca,'ytick', 0:440:4000); and tick marks
title('frequencies on a piano keyboard');
xlabel('{\itk}, piano key');
ylabel('{\itf} (Hz)');
legend(' all 88 keys', ' ''A'' keys only', 'location', 'nw');
grid on;
print –depsc octave2.eps % save plot in color EPS file
print –dmeta octave2.wmf % save plot in windows metafile

note: we defined fa as a subset of f,


but we could have defined it directly as,
fa = f0 * 2.^(ka/12);
3d octave 4th octav e
C# D# F# G# A# C# D# F# G# A#
Db Eb Gb Ab Bb Db Eb Gb Ab Bb

0 1 2 3 4 5 6 7 8 9 10 11 12

B C D E F G A B C D E F G A B C

A3 A4
middle C is 3/12 of an 220 Hz 440 Hz
octave above A3, or, middle C
9/12 octaves below A4 261.63 Hz
. 3/12 . -9/12
261.63 = 220 2 = 440 2

4th octave keys, k = 0:12, MATLAB index = k+1 = 1:13


major keys are a subset of k, m = [0, 2, 4, 5, 7, 9, 11, 12]
calculate, play, and print frequencies in 4th octave

fc = 220 * 2^(3/12); % middle C frequency


k = 0:12; % keys in 4th octave only
f = fc * 2.^(k/12); % frequencies of 4th octave

% fc = 440 * 2^(-9/12); % alternative calculation

Next, for each f of the major keys, y(t)


we generate a tone of half-second
duration & play it on the PC’s sound
t
card (at the card’s default sampling
0 0.5
rate, fs = 8192 samples/sec): sec
y(t) = sin(2  f t), 0  t  0.5 sec

time samples are spaced at the default


i.e., t = 0 : T : 0.5 sampling interval T = 1/fs = 0.122 msec
generate & play major notes in 4th octave

fs = 8192; T = 1/fs; % default sampling rate


Tmax = 0.5; % half-second duration for notes
t = 0:T:Tmax; % length(t) = 4097 points
% steps of T = 1/fs = 0.1221 msec

m = [0 2 4 5 7 9 11 12]; % major keys in 4th octave


% CDEFGABC = do re mi fa sol la si do

for i=m+1, % m+1 = [1 3 5 6 8 10 12 13]


y = sin(2*pi*f(i)*t); % y has half-second duration
sound(y,fs); % play y at rate fs
end

pause; % pause until a key is depressed

for i=fliplr(m+1), % fliplr(m+1)=[13 12 10 8 6 5 3 1]


y = sin(2*pi*f(i)*t);
sound(y,fs); % play them in reverse order
end
formatted printing of frequencies and key names

k oct=k/12 f=fc*2^(k/12) keys


----------------------------------------
0 0.0000 261.63 C do
1 0.0833 277.18 C#
2 0.1667 293.66 D re
3 0.2500 311.13 D#
4 0.3333 329.63 E mi
5 0.4167 349.23 F fa
6 0.5000 369.99 F#
7 0.5833 392.00 G sol
8 0.6667 415.30 G#
9 0.7500 440.00 A la
10 0.8333 466.16 A#
11 0.9167 493.88 B si
12 1.0000 523.25 C do

cell arrays
% formatted printing of frequencies and key names
% define cell arrays of key names to facilitate printing

keys = {'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#',...
'A', 'A#', 'B', 'C'};
empty string

doremi = {'do', '', 're', '', 'mi', 'fa', '', 'sol',...


'', 'la', '', 'si', 'do'};
cell arrays use {…}
fprintf('\n');
fprintf(' k oct=k/12 f=fc*2^(k/12) keys\n');
fprintf('----------------------------------------\n');
for i=k+1,
fprintf('%2d %6.4f %6.2f %-2s %-3s\n', ...
i-1, k(i)/12, f(i), keys{i}, doremi{i});
end
i-th entry of cell arrays ellipsis
continues to
next line
>> help fprintf % formatted printing
>> doc fprintf

You might also like