SUNY Geneseo Department of Mathematics
Monday, October 19
Math 230 01
Fall 2015
Prof. Doug Baldwin
meshgrid
for Building Function Tablesmeshgrid
constructs 2 matrices to use as pairs>> x = 1 : 5
x =
1 2 3 4 5
>> y = 1: 5
y =
1 2 3 4 5
>> [ A, B ] = meshgrid( x, y )
A =
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
B =
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
>> A .* B
ans =
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
>> x
x =
1 2 3 4 5
>> z = [ 10 20 30 40 ]
z =
10 20 30 40
>> [ C, D ] = meshgrid( x, z )
C =
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
D =
10 10 10 10 10
20 20 20 20 20
30 30 30 30 30
40 40 40 40 40
>> C .* D
ans =
10 20 30 40 50
20 40 60 80 100
30 60 90 120 150
40 80 120 160 200
<
, >
, <=
,
>=
, ==
, ~=
)==
vs =
while
loopwhile expression
…
end
x = some positive integer
log = 0
while x > 1
x = x / base
log = log + 1
x = 100;
myLog = 0;
while x > 1
x = x/10;
myLog = myLog + 1;
end
input
fprintf