Documente Academic
Documente Profesional
Documente Cultură
sm
12
8
4
0
-4
-8
12
-16
-8
16
sin x
z
6
4
2
20
64
1 / 23
x sin y
12
8
4
0
-4
-8
12
-16
-8
16
sin x
cos x
z
6
4
2
20
64
x sin y
x y
Adding
__more__entries__to__the__"Multiple
__values"__icon:
The "Multiple values" icon produces two entries by default.
However, you can insert more entries by following this
procedure:
2 / 23
12
8
4
0
-4
-8
12
-16
sin x
cos x
sin 2 x
2 - red
4 - magenta, etc.
3 / 23
-8
16
z
6
4
2
20
64
x sin y
x y
x y
Icons__in__the__"Plot"
__palette: -> -> -> -> -> -> ->
(1)
(2)
(3)
(4)
(5)
(6)
__of__"Scale"__in__a__2D__graph:
Detalles
* ZOOM IN or OUT: Click on the "Scale" icon, icon (2), then click on
the graph (also for 3D plots):
- ZOOM IN: Drag the mouse inwards, towards the origin, to decrease
size of axes divisions
- ZOOM OUT: Drag the mouse outwards, away from the origin, to increase
size of axis divisions
* Alternatively, to ZOOM IN or OUT, click on the "Scale" icon, click
inside the graph and use the mouse wheel (also for 3D plots):
- ZOOM IN: roll mouse wheel up
- ZOOM OUT: roll mouse wheel down
* ZOOM IN or OUT on the x-axis only: Click on the "Scale" icon, click
on the graph, hold the [SHIFT] key, then:
- ZOOM IN X-AXIS: roll mouse wheel up
- ZOOM OUT X-AXIS: roll mouse wheel down
* ZOOM IN or OUT on the y-axis only: Click on the "Scale" icon, click
on the graph, hold the [CTRL] key, then:
- ZOOM IN Y-AXIS: roll mouse wheel up
- ZOOM OUT Y-AXIS: roll mouse wheel down
EXAMPLE 4A - Changing the size of the graph window in 2D:
Click on the graph window, then drag one of the three black handlers in
the graph window to adjust its size
1
4 / 23
(2)
64
y
2
48
0
32
-2
16
sin x
-8
-4
(3)
x
y
8
-16
-32
-4
-48
-8
-16
-64
sin x
-8
sin x
z
sin x
cos y
4
2
20
64
4
2
20
64
sin x
cos y
sin x
cos y
5 / 23
12
y
4
-8
-4
-12
-8
12
-4
-16
-8
16
sin x
-16-8
16
sin x
y6
2
20
64
x cos y
x y
42 0 2
y sin x
x cos y
x y
Detalles
__of__"Scale"__in__a__2D__graph__(repeated):
6 / 23
y sin x
24
* ZOOM IN or OUT: Click on the "Scale" icon, icon (2), then click on
the graph (also for 3D plots):
- ZOOM IN: Drag the mouse inwards, towards the origin, to decrease
size of axes divisions
- ZOOM OUT: Drag the mouse outwards, away from the origin, to increase
size of axis divisions
* Alternatively, to ZOOM IN or OUT, click on the "Scale" icon, click
inside the graph and use the mouse wheel (also for 3D plots):
- ZOOM IN: roll mouse wheel up
- ZOOM OUT: roll mouse wheel down
* ZOOM IN or OUT on the x-axis only: Click on the "Scale" icon, click
on the graph, hold the [SHIFT] key, then:
- ZOOM IN X-AXIS: roll mouse wheel up
- ZOOM OUT X-AXIS: roll mouse wheel down
* ZOOM IN or OUT on the y-axis only: Click on the "Scale" icon, click
on the graph, hold the [CTRL] key, then:
- ZOOM IN Y-AXIS: roll mouse wheel up
- ZOOM OUT Y-AXIS: roll mouse wheel down
12
8
4
0
-4
y
-8
12
1
-2
-1
sin x
0.5
0
-0.5
-1
-16
sin x
7 / 23
-8
16
y
0.75
0.5
0.25
-0.25
-0.5
-0.75
-6
-4
-2
sin x
Note: Use the "Refresh" option in the "Plot" menu
to recover the original version of any plot.
EXAMPLE 6B - Scaling (zooming) a 3D graph:
2
20
64
0
21
sin x y
cos x y
sin x y
cos x y
Examples
__of__other__types__of__graphs
__in__2-D
The following examples show other ways to produce 2D graphics. Data for
a graph y = f(x) can be generated by using a vector of values of x, then
generating a vector of values of y. The two vectors are then put
together into a matrix, whose name is used in the 2D graph placeholder
instead of f(x).
EXAMPLE 7 - Plotting a function using vectors:
Vectors of x and y data are created using ranges,
example:
x
..
20
n length x
n 41
8 / 23
for k
1 .. n
sin x
2
k
sin 2 x
... etc.
augment x , y
y
1.5
1
0.5
0
-0.5
-2
M
Using points or lines for a plot:
y
2
1.5
1
0.5
0
-0.5
-4
-1
-2
..
20
for k 1 .. n
sin x
y
k
k
x
length x
n 41
augment x , y
9 / 23
12
y
1
8
0.5
-4
-0.5
-8
12
-16
-8
-1
16
M
cos x
-8
-6
-4
-2
M
cos x
1 - Original graph
..
50
length t
,
for k 1 .. n
x
sin 3 t
k
k
y
M
2 cos 2 t
augment x , y
y
-1
-1
-2
-1
-0.5
0.5
-2
-1
-0.5
0.5
M
1 - Using "Plot by Lines" option
in the "Plot" palette
.. 2
50
length
0,
for k 1 .. n
r
2 1 2 sin
k
k
for k
xx
yy
P
1 .. n
r cos
k
k
k
k
sin
Generate coordinates:
x = r cos()
y = r sin()
augment xx , yy
y
6
5
0
-1
-4
-2
-1
-4
-2
0 , 0.1 .. 10
length t
n 101
11 / 23
for k 1 .. n
x
sin t
k
k
y
z
M
cos t
k
2
augment x , y , z
1 x
2 x 5
g x
2 x 5
Using graphics and zooming the intersection we estimate the solution to be close to
x = 1.80
y
16
4.375
12
4.25
4.125
0
-4
-4
-2
f x
g x
3.875
1.625
1.6875
1.75
1.8125
f x
g x
solve x
12 / 23
1 x
2 x 5, x
1.78
1.875
Solution:
=========
L
Write out all the given data without units, but using the
proper set of units for the English System:
6
ee 5 10 (ft)
1000
(ft)
D 0.15 (ft)
z 6 (ft)
5
1.2 10
(ft^2/s)
g 32.2 (m/s^2)
Km 0.5 1.0 6.0 , i.e., Km 7.5
14.09
138.02
2267.62
0.25
fSJ k , r
log10
k
3.7
5.74
0.9
r
2
ee
8 Q
4 Q
Km fSJ
,
4
D
D
2
g D
hP z
hP a b Q c Q
2
ee
8 Q
4 Q
Km fSJ
,
4
D
D
2
g D
L
D
13 / 23
hP2 Q
[1]
[2]
L
D
a b Q c Q
14
12
10
8
6
4
2
0
-2
0.07
hP1 x
hP2 x
Notice that, even though we defined hP1 and
hP2 as functions of Q, when using the 2D plot,
we need to define them as functions of x.
The exact solution can be found by solving the equation: hP1(Q)=hP2(Q)
solve hP1 Q
hP2 Q , Q , 0 , 1
3.01 10
z8
2
20
64
2
2
x
y8
02
4 6 8x
x y
x y
14 / 23
z8
z8
4
02
4 6 8x
02
4 6 8x
y8
y8
x y
x y
z
27
18
4
2
20
4
6
9
18
y27
x y
18 27
x
x 2 y
Note: Use the "Refresh" option in the "Plot" menu to recover the original version of any plot.
EXAMPLE 15 - The following examples use more complex 3D surfaces:
15 / 23
02
2
46
20
64
sin x
z
8
6
2
x6420
2
y8
x y
02 4
6 8x
x y
x y
The type of 3D graphs of surfaces produced by SMath Studio are referred to as wireframe plots.
EXAMPLE 16 - The following examples show more than one surface plot together in 3D:
8
z
6
z8
2
8x
6420
y8
2
2
4
6
y8
x y
x y
x y
x y
x 2 y
16 / 23
2 4 6 8x
z
9
z8
6
6 3
y9
2
3
x
y8
5
x
x
2
2 4 6 8x
sin x
sin y
z8
2 4 6 8x
2
4
6
y8
x y
M
2 , 1.9 .. 2
length t
n 40
for k
x1
y1
z1
k
k
k
1 .. n
1 5 t
k
1 4 t
1 8 t
for k
x2
y2
z2
augment x1 , y1 , z1
k
k
k
1 .. n
1 3 t
1 t
t
augment x2 , y2 , z2
17 / 23
20
64
20
64
z
6
4
2
20
64
P
Q
Plot__specifications
__using__SMath__Studio
__0.89__-__Release__8
SMath Studio 0.89 - Release 8 includes the ability of specifiying
four different types of symbols for the graphs, modifying the
size of the symbols, and select the color of the symbol. This is
accomplished by building a matrix that includes the coordinates
(x,y), the character, its size, and the color, in that order.
* Characters: you can select for plotting the characters:
"x"
"*"
"."
"o"
* Size: given in pixels, e.g., 5, 10, 20, 100, etc.
* Colors available (figure below split for printing purposes):
18 / 23
You can write them in lower case lettes , as shown above, or all in upper
case letters, or combinations of upper and lower case letters. For example,
you could write in your color specification "darkblue", "DARKBLUE", or
"DarkBlue", and the result would be the same. Additionally, you can have
spaces in the color specification which will be ignored by SMath Studio in
producing the output to the graphic canvas. For example, you can write
"Dark Blue", and it will be interpreted as "darkblue".
NOTE: Any color combination, such as "LightRed", not defined above,
will produce, by default, the color black.
2 5 "" 15 "Blue"
ch02
19 / 23
12
-4
-4
-8
-8
-16
-8
16
12
ch01
-16
-8
ch02
ch03
10 10
"Gilberto E. Urroz" 12
"Red"
10 5 "CEE 3510 - Hydraulics" 12 "Dark Blue"
10 0
"Fall Semester 2010" 12
"Green"
10 5
"Using SMath Studio" 12 "Dark Green"
10 10 "Utah State University" 12
"Blue"
y
12
Gilberto E. Urroz
8
4
0
-4
-8
12
Utah
State
-8
0 University
8
-16
16
ch03
A__program__to__plot__single
__data__sets__with__different
__symbols,
__sizes,
__and__colors
The following program was made available by Prof. Radovan Omorjan in the
SMath Studio Forum. The program takes vectors of values (x,y) and creates
a plot matrix for the data using a specified character (char), size, and
color. This program operates only in SMath Studio version 0.89 release 8,
and later. The expression for the program, or function, is:
plotG x , y , char , size , color
length x
plot augment x
1,
1,
for i 2 .. n
plot stack plot , augment x
plot
20 / 23
i,
i,
16
0 , 0.5 .. 10
n 21
length x
for k 1 .. n
y
sin x
k
k
The plots are shown below:
plot1 plotG x , y , "." , 25 , "Light Green"
1.5y
1.5
0.5
0.5
-0.5
-1
-1
2
10
plot1
1.5
0.5
0.5
10
-0.5
-1
-1
2
plot3
-0.5
-1.5
plot4
-1.5
0
plot2
1.5
-0.5
0 , 0.5 .. 10
length x
n 21
21 / 23
10
for k 1 .. n
y
sin x
k
k
z
r
k
k
sin 2 x
cos 3 x
k
k
sZ
sR
stack sY , sZ
MZR
stack sZ , sR
MYR
stack sY , sR
MYZR stack sY , sZ , sR
Some plots based on the matrices, and the original functions used to produce the
matrix data, are shown next:
1.5
y
1.5
0.5
0.5
0
-0.5
-0.5
-1
-1
-1.5
-1.5
10
-2
2
10
MZR
MYZ
y
y
1.5
1
0.5
0.5
0
-0.5
-0.5
-1
-1
0
10
MYR
-1.5
MYZR
22 / 23
10
1
0.5
0.5
0
-0.5
-0.5
-1
-1 5
-2
10
12
MYZ
sin x
-1
MYZ
sin x
sin 2 x
23 / 23
10