Now assume a general nelement sequence for x Write an expres
Solution
Matlab Code:
Please run each of them individually
%first one
 x = [10 2 14 7 9 12 31 6 4 7];
 y=fliplr(x);%flips the vector
 disp(y);
%second one
 x = [10 2 14 7 9 12 31 6 4 7];
 [r c]=size(x);
 y=zeros;
 index = 1;
 for i=1:2:c%i increments by 2
 y(index)=x(i);
 index = index+1;
 end
 disp(y);
 %third one
 y=zeros;
 index = 1;
 for i=1:3:c%i increments by 3
 y(index)=x(i);
 index = index+1;
 end
 disp(y);
%fourth one
 y=zeros;
 index = 1;
 for i=0:c
 if i==0
 y(index)=0;
 else
 y(index)=x(i);
 end
 index = index+1;
 end
 disp(y);
%fifth one
 y=zeros;
 index = 1;
 for i=-1:c
 if i<1
 y(index)=0;
 else
 y(index)=x(i);
 end
 index = index+1;
 end
 disp(y);
 %sixth one
 x = [5 3 7];
 y = [x x x x x x x x x x];
 disp(y);
%seventh one
 x = [10 2 14 7 9 12 31];
 [r c]=size(x);
 y=zeros;
 index = 1;
 for i=1:c
 y(index)=x(i);
 y(index+1)=x(i);
 index = index+2;
 end
 disp(y);
%8th one
 x = [10 2 14 7 2 5];
 [r c]=size(x);
 y = zeros;
 for i=1:c
 if i==1
 y(i)=x(i);
 else
 y(i)=x(i)+y(i-1);
 end
 end
 disp(y);
Output:
1. output:
Columns 1 through 7
7 4 6 31 12 9 7
Columns 8 through 10
14 2 10
2.output.
10 14 9 31 4
3.ouput
10 7 31 7
4.output
Columns 1 through 7
0 10 2 14 7 9 12
Columns 8 through 11
31 6 4 7
5.output
Columns 1 through 7
0 0 10 2 14 7 9
Columns 8 through 12
12 31 6 4 7
6.output
Columns 1 through 6
5 3 7 5 3 7
Columns 7 through 12
5 3 7 5 3 7
Columns 13 through 18
5 3 7 5 3 7
Columns 19 through 24
5 3 7 5 3 7
Columns 25 through 30
5 3 7 5 3 7
7.ouput
Columns 1 through 6
10 10 2 2 14 14
Columns 7 through 12
7 7 9 9 12 12
Columns 13 through 14
31 31
8 output
10 12 26 33 35 40



