Professional Documents
Culture Documents
pg 1/5
pg 2/5
04
=
4 4 < 6
!
4
>6
Examples:
>> FinalPiece(3)
ans =
1.7321
>> Y = FinalPiece(5.5)
Y =
-4
>> yy = FinalPiece(10)
yy =
-25
Input
Restrictions
&
special
cases:
The
function
should
return
a
red
error
message
for
the
following
conditions.
Publish
all
three
sample
cases
as
pdf,
and
upload
both
FinalPiece.m
and
FinalPiece.pdf
to
Blackboard
pg 3/5
Code
Requirements:
The
script
file
must
call
(use)
the
function
FinalPiece
to
plot
the
piecewise
function.
No
credit
will
be
given
if
the
plot
is
generated
any
other
way.
Use
an
open
circle
for
inequalities,
and
closed
circle
for
equalities
Plot
smooth,
separated
curves
Use
the
plot
command
onlyno
other
MATLAB
plotting
functions
are
permitted.
Publish
the
script
file
as
FinalPiecePlot.pdf.
If
the
plot
does
not
show
in
the
pdf
file,
you
will
receive
a
grade
of
zero
for
this
part
of
the
assignment.
Helpful
hints
Remember
to
suppress
output
in
both
the
function
&
script
files.
Multiple
plot
commands
will
be
needed.
Here
is
code
to
plot
a
filled
red
circle
at
x=2
&
y=3:
plot(2,3,'ro','markerfacecolor','r')
Publish
as
pdf,
&
upload
FinalPiecePlot.m
&
FinalPiecePlot.m
to
Blackboard
pg 4/5
Part
2b:
Table
of
GCD
&
LCM
Write
a
MATLAB
script
GCD_LCMtable
to
print
a
table
of
10
randomly-generated
numbers,
and
their
gcd
&
lcm,
using
your
function
GCD_LCM.
Here
is
the
code
to
use
for
generating
random
numbers:
Sample
Results
a = randi([10 30],[1,10]);
b = randi([10 30],[1,10]);
a
b
GCD LCM
30
10
10
30
21
28
7
84
Code
Requirements:
20
29
1
580
14
26
2
182
You
must
use
function
GCD_LCM.
No
credit
20
12
4
60
will
be
given
if
not
used.
23
15
1
345
Do
not
use
the
table
function
24
17
1
408
18
17
30
24
12
25
6
1
5
72
204
150
pg 5/5
0
4
6
8
>> FloatZero(b)
ans =
5
0
4
-1
2
1
0
0
4
-6
Code
Requirements:
No
vectorization
is
allowed,
nor
any
functions,
such
as
find,
that
work
on
an
entire
array.
Helpful
hints
Although
you
are
not
sorting
the
entire
array,
researching
the
bubble
sort
algorithm
could
be
useful.
This
does
not
mean
cut
and
paste
MATLAB
code
that
you
might
find!
Publish
the
first
sample
case
as
pdf.
Upload
files
FloatZero.m
&
FloatZero.pdf