English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-07-23 06:45:02 · 3 answers · asked by Jayjay 1 in Computers & Internet Programming & Design

Oops using C++.....and Dev c++ compiler.

2006-07-23 06:55:00 · update #1

3 answers

You can't. Arrays are scalar quantities. Vectors are different - they have magnitude and direction. You can multiply divide etc a array and a vector but you can't interchange them!

2006-07-23 06:52:09 · answer #1 · answered by Anonymous · 0 2

colon (:)

Create vectors, array subscripting, and for-loop iterators

Description

The colon is one of the most useful operators in MATLAB. It can create vectors, subscript arrays, and specify for iterations.

The colon operator uses the following rules to create regularly spaced vectors:

j:k
is the same as [j,j+1,...,k]
j:k
is empty if j > k
j:i:k
is the same as [j,j+i,j+2i, ...,k]
j:i:k
is empty if i == 0, if i > 0 and j > k, or if i < 0 and j < k

where i, j, and k are all scalars.

Below are the definitions that govern the use of the colon to pick out selected rows, columns, and elements of vectors, matrices, and higher-dimensional arrays:

A(:,j)
is the jth column of A
A(i,:)
is the ith row of A
A(:,:)
is the equivalent two-dimensional array. For matrices this is the same as A.
A(j:k)
is A(j), A(j+1),...,A(k)
A(:,j:k)
is A(:,j), A(:,j+1),...,A(:,k)
A(:,:,k)
is the kth page of three-dimensional array A.
A(i,j,k,:)
is a vector in four-dimensional array A. The vector includes A(i,j,k,1), A(i,j,k,2), A(i,j,k,3), and so on.
A(:)
is all the elements of A, regarded as a single column. On the left side of an assignment statement, A(:) fills A, preserving its shape from before. In this case, the right side must contain the same number of elements as A.

Examples

Using the colon with integers,

*

D = 1:4

results in

*

D =
1 2 3 4

Using two colons to create a vector with arbitrary real increments between the elements,

*

E = 0:.1:.5

results in

*

E =
0 0.1000 0.2000 0.3000 0.4000 0.5000

The command

*

A(:,:,2) = pascal(3)

generates a three-dimensional array whose first page is all zeros.

*

A(:,:,1) =
0 0 0
0 0 0
0 0 0

A(:,:,2) =
1 1 1
1 2 3
1 3 6

Also I cant go in details therefore here is the link mate

http://www.informit.com/articles/article.asp?p=25281&rl=1

2006-07-25 06:09:48 · answer #2 · answered by Joe_Young 6 · 1 0

What software are you using?

2006-07-23 13:51:18 · answer #3 · answered by jimp178 1 · 0 0

fedest.com, questions and answers