illustration of modifying elementsillustration


Illustration of Modifying Elements:

Illustration, the fifth element in the vector newvec is 9

>> newvec(5)

ans =

9

The subset of a vector, that would be a vector itself, can also be achieved using the colon operator. For illustration, the following statement would get the fourth through sixth elements of the vector newvec, and store the result in the vector variable b:

>> b = newvec(4:6)

b =

7  9  3

Any vector can be used for the indices in the other vector, not merely one created using the colon operator. For illustration, the following would get the first, fifth, & tenth elements of the vector newvec:

>> newvec([1 5 10])

ans =

1  9  15

The vector [1 5 10] is termed as index vector; it indicates the indices in the original vector which are being referenced.

The value stored in a vector element can be changed by identifying the index or subscript. For illustration, to change the second element from the vector b to now store the value 11 rather than of 9:

>> b(2) = 11

b =

7  11  3

Request for Solution File

Ask an Expert for Answer!!
Applications of MATLAB: illustration of modifying elementsillustration
Reference No:- TGS0174718

Expected delivery within 24 Hours