Now assumc a general nelement sequence for write an exressio

Now assumc a general n-element sequence for write an exression for each element of the sequece come up with a general rule for y, that captures the pattem write a program to do the computation and print the results to the screen. Repeat above steps for the following sequence pairs: Here we will introduce a parameter k which specifies the position in x where the nmber is removed. In the above case, k = 3 Try values of and other sequences and them write a general rule.

Solution

%First one:
x = [10 2 14 7 9 12 31 6 4];
k = input(\'Enter k:\ \');
x(k)=[];%deletes kth column
disp(x);

%second one
x = [10 2 14 7 9 12 31 6 4];
[r c]=size(x);%gives no. of rows and columns
k = input(\'Enter k:\ \');
p = input(\'Enter p:\ \');
y = [x(1:k) p x(k+1:c)];%modifiying array
disp(y);

Output:

1.output:

Enter k:
4
Columns 1 through 7

10 2 14 9 12 31 6

Column 8

4

2.output:

Enter k:
4
Enter p:
24
Columns 1 through 6

10 2 14 7 24 9

Columns 7 through 10

12 31 6 4

 Now assumc a general n-element sequence for write an exression for each element of the sequece come up with a general rule for y, that captures the pattem writ

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site