Ihsan Ghani
Ihsan Ghani
Roll No : 23-CSE-10
A=[1 0 4 5 3 9 0 2]
A =
1 0 4 5 3 9 0 2
a=[4 5 0 2 0 0 7 1]
a =
4 5 0 2 0 0 7 1
B=[A a]
B =
1 0 4 5 3 9 0 2 4 5 0 2 0
0 7 1
C=[a A]
C =
4 5 0 2 0 0 7 1 1 0 4 5 3
9 0 2
D = [0 0 0 . . . 0] with fifty 0’s
D=zeros(10,5)
D =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
E = [1 1 1 . . . 1] with a hundred 1’s
E=ones(10,10)
E =
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
F = [1 2 3 4 . . . 30]
F=[1:30]
F =
1 2 3 4 5 6 7 8 9 10 11 12 13
14 15 16 17 18 19 20 21 22 23 24 25 26
27 28 29 30
G = [25 22 19 16 13 10 7 4 1]
G=[25:3:1]
G =
H=[0:0.2:2.0]
H =
V1 = [1 2 3 4 5 6 7 8 9 0]
Solution:
V1=[1:9 0]
V1 =
1 2 3 4 5 6 7 8 9 0
V2=[0.3 1.2 0.5 2.1 0.1 0.4 3.6 4.2 1.7 0.9]
V2 =
V3=[4 4 4 4 3 3 2 2 2 1]
V3 =
4 4 4 4 3 3 2 2 2 1
V1=V2+V3
V1 =
V1(5)
ans =
3.1000
V2(5)
ans =
0.1000
V3(5)
ans =
V1(0)
V1(11)
Index exceeds the number of array elements. Index must not exceed 10.
V5=[0.4 3.6 4.2 1.7 0.9]
V5 =
V6=V2*[0.3:0.1 0.4:0.9]
V6 =
V6 =
V4=V2(1:5)
V4 =
V5 =
V6=V2;
V6(:,6)
ans =
0.4000
V7=V2;
V7(:,7)=[1.4]
V7 =
V8=V2;
V8([1 3 5 7 9])%
ans =
V1+5
ans =
V1+V2
ans =
V1-V3
ans =
V1.*V2
ans =
V1*V2
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of
columns in the first matrix matches the number of rows in the second matrix.
To operate on each element of
the matrix individually, use TIMES (.*) for elementwise multiplication.
Related documentation
V1.^2
ans =
V1,^V3
V1,^V3
↑
Invalid use of operator.
V1.^V3
ans =
1.0e+03 *
V1^V3
Error using ^
Incorrect dimensions for raising a matrix to a power. Check that the matrix is
square and the power is a scalar. To operate on each element of the matrix
individually, use POWER
(.^) for elementwise power.
V1==V3
ans =
0 0 0 0 0 0 0 0 0 0
V1>6
ans =
0 0 0 1 0 0 0 1 0 0
V3-(V1-2)
ans =
(V1>2)&(V1<6)
ans =
1 1 1 0 1 1 1 0 1 0
(V1>2)|(V1<6)
ans =
1 1 1 1 1 1 1 1 1 1
any(V1)
ans =
logical
1
all(V1)
ans =
logical