0% found this document useful (0 votes)
19 views6 pages

Array Addressing

Uploaded by

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

Array Addressing

Uploaded by

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

Array Addressing

Command windows:
a=
- 12*y*z - 20
b=
- 16*z - 40
c=
-160
a=
Columns 1 through 4
1.0000 3.0000 5.0000 7.0000
10.0000 12.5000 15.0000 17.5000
65.0000 65.0000 62.0000 63.0000
Column 5
9.0000
20.0000
2.0000
>> c=a(2:)
c=a(2:)

Error: Invalid expression. When calling a
function or indexing a variable, use
parentheses. Otherwise, check for mismatched
delimiters.

>> c=a(1,:)
c=
1 3 5 7 9
>> c=a(1,2)
c=
3
>> c=a(1:3,3)
c=
5
15
62
>> c=a()
c=
Columns 1 through 4
1.0000 3.0000 5.0000 7.0000
10.0000 12.5000 15.0000 17.5000
65.0000 65.0000 62.0000 63.0000
Column 5
9.0000
20.0000
2.0000
>> c=a(1,1:3)
c=
1 3 5
>> c=a(1:3,1)
c=
1
10
65
>> c=a(1:3,1:3)
c=
1.0000 3.0000 5.0000
10.0000 12.5000 15.0000
65.0000 65.0000 62.0000
>> a=
a=

Error: Invalid expression. Check for missing or extra characters.

>> a
a=
1.0000 3.0000 5.0000 7.0000 9.0000
10.0000 12.5000 15.0000 17.5000 20.0000
65.0000 65.0000 62.0000 63.0000 2.0000
>> c=a(2:3,3:5)
c=
15.0000 17.5000 20.0000
62.0000 63.0000 2.0000
>> c=a(1:3,1:2:5)
c=
1 5 9
10 15 20
65 62 2
>> c=a(1:3,1;3;5)
c=a(1:3,1;3;5)

Error: Invalid expression. When calling a function or indexing a variable, use
parentheses. Otherwise, check for mismatched delimiters.

>> c=a(1:3,1,3,5)
Index in position 3 exceeds array bounds (must not exceed 1).
>> c=a(1:3,1:2:5)
c=
1 5 9
10 15 20
65 62 2
>> c=a(1:3,1:3:5)
c=
1.0000 7.0000
10.0000 17.5000
65.0000 63.0000
>> a=
a=

Error: Invalid expression. Check for missing or extra characters.

>> a
a=
1.0000 3.0000 5.0000 7.0000 9.0000
10.0000 12.5000 15.0000 17.5000 20.0000
65.0000 65.0000 62.0000 63.0000 2.0000
>> c=a(1:2:3,1:2:4)
c=
1 5
65 62
>> c=a(1:2:3,1:2:5)
c=
1 5 9
65 62 2
>> c=a(1:2:3,1:3:4)
c=
1 7
65 63
>> c=a(1:2:3,1:3:4:4)
c=
1 3 5 7
65 65 62 63
>> c=a(1:2:3,1:3:3:4)
c=
1 3 5 7
65 65 62 63
>> c=a(1:2:3,1:3:4)
c=
1 7
65 63
>> c=a(1:2:3,1:3:4)
c=
1 7
65 63
>> c=a(1:4:7)
c=
1.0000 12.5000
>> c=a(1,4:7)
Index in position 2 exceeds array bounds (must not exceed 5).
>> c=a(1,4:6)
Index in position 2 exceeds array bounds (must not exceed 5).
>> a
a=
1.0000 3.0000 5.0000 7.0000 9.0000
10.0000 12.5000 15.0000 17.5000 20.0000
65.0000 65.0000 62.0000 63.0000 2.0000
>> c=a(1,4:5)
c=
7 9
>> c=a(1,4:end)
c=
7 9
>> 'huzaefa'
ans =
'huzaefa'
>> A=1:1:5
A=
1 2 3 4 5
>> a
a=
1.0000 3.0000 5.0000 7.0000 9.0000
10.0000 12.5000 15.0000 17.5000 20.0000
65.0000 65.0000 62.0000 63.0000 2.0000
>> c=a(1:1:3,6)=[26 62 63]
c=a(1:1:3,6)=[26 62 63]

Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To
compare values for equality, use '=='.
>> a(1:1:3,6)=26 62 63
a(1:1:3,6)=26 62 63

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:1:3,6)=26,62,63
a=
1.0000 3.0000 5.0000 7.0000 9.0000 26.0000
10.0000 12.5000 15.0000 17.5000 20.0000 26.0000
65.0000 65.0000 62.0000 63.0000 2.0000 26.0000
ans =
62
ans =
63
>> a(1:1:3,6)=26;62;63
ans =
63
>>
>>
>>
>>
>>
>> a=
a=

Error: Invalid expression. Check for missing or extra characters.

>> a
a=
1.0000 3.0000 5.0000 7.0000 9.0000 26.0000
10.0000 12.5000 15.0000 17.5000 20.0000 26.0000
65.0000 65.0000 62.0000 63.0000 2.0000 26.0000
>> a(1:1:3,6)=[]
A null assignment can have only one non-colon index.
>> a(1,6)=[]
A null assignment can have only one non-colon index.
>> a(:,6)=[]
a=
1.0000 3.0000 5.0000 7.0000 9.0000
10.0000 12.5000 15.0000 17.5000 20.0000
65.0000 65.0000 62.0000 63.0000 2.0000
>> a(:,6)=26 62 32
a(:,6)=26 62 32

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(:,6)=26;32;23
ans =
23
>>
>>
>>
>>
>>
>>
>>
>>
>> a(:,6)=[26;62;32]
a=
1.0000 3.0000 5.0000 7.0000 9.0000 26.0000
10.0000 12.5000 15.0000 17.5000 20.0000 62.0000
65.0000 65.0000 62.0000 63.0000 2.0000 32.0000
>> a(4:1)=[1 2 3 4 5]
Unable to perform assignment because the left and right sides have a different
number of elements.
>> a(4:1)=[1,2,3,4,5]
Unable to perform assignment because the left and right sides have a different
number of elements.
>> a(4,:)=[1,2,3,4,5]
Unable to perform assignment because the size of the left side is 1-by-6 and the
size of the right side is 1-by-5.
>> a(4,:)=[1,2,3,4,5,6]
a=
1.0000 3.0000 5.0000 7.0000 9.0000 26.0000
10.0000 12.5000 15.0000 17.5000 20.0000 62.0000
65.0000 65.0000 62.0000 63.0000 2.0000 32.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
>> a(5,:)=[1,2,3,4,5,6]
a=
1.0000 3.0000 5.0000 7.0000 9.0000 26.0000
10.0000 12.5000 15.0000 17.5000 20.0000 62.0000
65.0000 65.0000 62.0000 63.0000 2.0000 32.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
>> a(10,:)=[1,2,3,4,5,6]
a=
1.0000 3.0000 5.0000 7.0000 9.0000 26.0000
10.0000 12.5000 15.0000 17.5000 20.0000 62.0000
65.0000 65.0000 62.0000 63.0000 2.0000 32.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
>> a(3,2:1:4)=[0 0 0]
a=
1.0000 3.0000 5.0000 7.0000 9.0000 26.0000
10.0000 12.5000 15.0000 17.5000 20.0000 62.0000
65.0000 0 0 0 2.0000 32.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
>> a(3,:)=[]
a=
1.0000 3.0000 5.0000 7.0000 9.0000 26.0000
10.0000 12.5000 15.0000 17.5000 20.0000 62.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
>> a(5:end,:)
ans =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
1 2 3 4 5 6
>> a(5:end,:)=[]
a=
1.0000 3.0000 5.0000 7.0000 9.0000 26.0000
10.0000 12.5000 15.0000 17.5000 20.0000 62.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
>> a(1:end,6)=[]
A null assignment can have only one non-colon index.
>> a(:,6)=[]
a=
1.0000 3.0000 5.0000 7.0000 9.0000
10.0000 12.5000 15.0000 17.5000 20.0000
1.0000 2.0000 3.0000 4.0000 5.0000
1.0000 2.0000 3.0000 4.0000 5.0000
>> a(3,3)=255556522556
a=
1.0e+11 *
0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 2.5556 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000
>> a(3,3)=69
a=
1.0000 3.0000 5.0000 7.0000 9.0000
10.0000 12.5000 15.0000 17.5000 20.0000
1.0000 2.0000 69.0000 4.0000 5.0000
1.0000 2.0000 3.0000 4.0000 5.0000
>> a(:,:)=69
a=
69 69 69 69 69
69 69 69 69 69
69 69 69 69 69
69 69 69 69 69
>> a(:,:)=100
a=
100 100 100 100 100
100 100 100 100 100
100 100 100 100 100
100 100 100 100 100

You might also like