Matvec Users’ Guide
Matvec Users' Guide
Matvec Users' Guide
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
2.4. MATRIX OBJECT 11<br />
Another method to create a vector object is to use one of object-creating function Vector(...) as shown<br />
below:<br />
> C = Vector(-5, 5, B)<br />
i = 1 i = 2 i = 3 i = 4<br />
-5 5 1 3<br />
The i’th element of vector A can be accessed by A(i). Note that vector indexing starts from one rather than<br />
zero. The usual algebraic operators such as +, -, *, /, .+, .-, .* ./,+=, -=, *=, /= are available.<br />
If both A and B are vectors, then A*B returns an inner product of vectors A and B, whereas A.*B returns<br />
a vector with each element being product of corresponding elements in A and B. The element-by-element<br />
division can be done by either A/B or A./B.<br />
The relational operators are ==, !=, , =. The logical operators are ||(OR), &&(AND) and<br />
.||, .&&.<br />
There are a lot of member functions for vectors such as max, min, mean, input, mat, diag, sin, etc.<br />
A vector (v) can be easily converted to any size of matrix by using v.mat(m,n) as long as there are enough<br />
elements to fill.<br />
2.4 Matrix Object<br />
See details in Chapter 3.<br />
2.5 String Object<br />
A string object in <strong>Matvec</strong> is defined as a sequence of characters. It can be created by using double-quotes<br />
operator ". For example,<br />
s = "Hello World";<br />
A string object can also be created from a scalar object using the string() function. For example,<br />
> "tan(10)="+string(tan(10))<br />
tan(10)=0.648361<br />
The operators and member functions for string objects are very limited. Indexing and concatenation<br />
works as usual. For example<br />
> s = "Hello World";<br />
> s.size()<br />
11<br />
> t = "Greetings From MATVEC";<br />
> s + t<br />
Hello WorldGreetings From MATVEC<br />
> s + ", " + t<br />
Hello World, Greetings From MATVEC<br />
> s([1,7])<br />
HW<br />
Some characters are so special that they cannot be included literally in a string object. Instead, they<br />
are represented with escape sequences. An escape sequence is a two-character sequence beginning with a<br />
backslash (\) followed by a special character. The following is a list of escape sequences implemented in<br />
<strong>Matvec</strong>: