Creation of Sets/Array in z^3
Jump to navigation
Jump to search
Tricks and Shortcuts
Description
*Creating an Array
- Comma(,) has to be used to separate the elements(especially when negative numbers are in an array). This removes the ambiguity.
For example:(without comma)
a = [1 2 3; -4*5 -4 6; 7 8 10]
This gives the answer as:
a = 1 2 3
-24 6
7 8 10
with comma:
a = [1 2 3; -4*5, -4 6; 7 8 10]
a = 1 2 3
-20 -4 6
7 8 10
*Notations
- The unit operators work for simple or matrix parameters on both sides. This makes |-| be available for non-unit based subtraction. This is possibly a better notation.
- To do unit based subtractions, do
A=[1m 2m]; B=[4m 5m]; c=A<->B c = [-3m -3m]
- Matrix subtraction, without units.
A=[1m 2m]; B=[4m 5m]; c=A|-|B c = [-3 -3]
*Creating an Array with an interval
- An array can be created within a given interval using this notation. Brackets() are important.
xmin = 1 xmax = 2 dx = 0.2 x = [(xmin-dx)..(xmax+dx)..(dx)]; x = [0.8 1 1.2000000000000002 1.4000000000000001 1.6 1.8 2 2.2]
- To remove the digits after one decimal, use round function.
x = [round((xmin-dx),1)..round((xmax+dx),1)..(dx)]; x = [1 1.2 1.4 1.6 1.8 2]
- To get the inverse of a matrix, add ~ to the array.
x = [round((xmin-dx),1)..round((xmax+dx),1)..(dx)]~
x = 1
1.2
1.4
1.6
1.8
2
*Evaluating a Function
- Calculating the value of function "u0" with corresponding values of x.
xmin = 1 xmax = 2 dx = 0.2 x = [(xmin-dx)..(xmax+dx)..(dx)]; u0 = EXP(-2<*>(x<->0.25)<^>2); u0 = [0.32465246735834974 0.16447445657715493 0.07100535373963703 0.026121409853918226 0.008188701014374078 0.002187491118182886]