0% found this document useful (0 votes)
13 views4 pages

Arreglos 5

The document demonstrates various MATLAB commands for creating, accessing, and manipulating vectors and matrices. It shows how to define vectors using brackets, access individual elements using indices, concatenate and slice vectors, perform element-wise operations like sine and logarithm, and calculate element-wise operations on matrices using vectors and arithmetic operators. Errors are displayed when trying to define matrices using parentheses instead of brackets.

Uploaded by

Shiavonne Patt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Arreglos 5

The document demonstrates various MATLAB commands for creating, accessing, and manipulating vectors and matrices. It shows how to define vectors using brackets, access individual elements using indices, concatenate and slice vectors, perform element-wise operations like sine and logarithm, and calculate element-wise operations on matrices using vectors and arithmetic operators. Errors are displayed when trying to define matrices using parentheses instead of brackets.

Uploaded by

Shiavonne Patt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MATLAB Command Window Page 1

>> x = [5 7 -2 4 -6]

x =

5 7 -2 4 -6

>> y = [2,1,3,7]

y =

2 1 3 7

>> z = [0 1 2,3 4,5]

z =

0 1 2 3 4 5

>> w = [1 ;2; 3]

w =

1
2
3

>>
>> x = [5 7 -2 4 -6];
>> x (2)

ans =

>> x (end)

ans =

-6

>>
>> x = [5 7 -2 4 -6];
>> x (6)=8

x =

5 7 -2 4 -6 8

>> x(10)=7

x =
MATLAB Command Window Page 2

Columns 1 through 7

5 7 -2 4 -6 8 0

Columns 8 through 10

0 0 7

>>
>> x = [5 7 -2 4 -6];
>> w = [1 2 3 4];
>> z1=[x w]

z1 =

Columns 1 through 7

5 7 -2 4 -6 1 2

Columns 8 through 9

3 4

>> z2=[x(1) w x(3)]

z2 =

5 1 2 3 4 -2

>>
>> x = [5 7 -2 4 -6];
>> x (2:4)

ans =

7 -2 4

>>
>> x = [1 2 3 4 5 6 7];
>> x(4) = []

x =

1 2 3 5 6 7

>> x(2:5) = []

x =

1 7
MATLAB Command Window Page 3

>>
>> x = [5 7 -2 4 -6];
>> x (1:2:5)

ans =

5 -2 -6

>>
>> x = [5 7 -2 4 -6];
>> x ( [3 5 1] )

ans =

-2 -6 5

>>
>> v=[1 2 3]

v =

1 2 3

>> sin(v)

ans =

0.8415 0.9093 0.1411

>> log(v)

ans =

0 0.6931 1.0986

>>
>> x=1:10

x =

Columns 1 through 7

1 2 3 4 5 6 7

Columns 8 through 10

8 9 10

>> y=x.^2-2*x-3
MATLAB Command Window Page 4

y =

Columns 1 through 7

-4 -3 0 5 12 21 32

Columns 8 through 10

45 60 77

>> a=(1 2 3), b=(-2 3 5)


a=(1 2 3), b=(-2 3 5)

Error: Invalid expression. Check for


missing multiplication operator, missing
or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets
instead of parentheses.

>> a=(1 2 3)
a=(1 2 3)

Error: Invalid expression. Check for


missing multiplication operator, missing
or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets
instead of parentheses.

>>

You might also like