Problem statement:
1)Generate a vector like 1,2,2,3,3,3,4,4,4,4
So if n = 3, then return
[1 2 2 3 3 3]
And if n = 5, then return
[1 2 2 3 3 3 4 4 4 4 5 5 5 5 5]
2) Generate a string like abbcccddddeeeee
So if n = 3, then return
'abbccc'
And if n = 5, then return
'abbcccddddeeeee'
Fundamental concept on string related problems in MATLAB:
https://www.youtube.com/watch?v=ikzmU...
CODE:
Fro printing integer sequence:
clc
x=input('Enter the number');
Y=[];
for i=1:x m=i; for i=1:m Y=[Y m]; end
end
disp(Y)
For printing character sequence:
clc
x=input('Enter the number');
m=97;
Y=[];
Y=[Y m];
for i=1:x-1 m=(97+i); for i=97:m Y=[Y m]; end
end
a=char(Y);
disp(a)
1)Generate a vector like 1,2,2,3,3,3,4,4,4,4
So if n = 3, then return
[1 2 2 3 3 3]
And if n = 5, then return
[1 2 2 3 3 3 4 4 4 4 5 5 5 5 5]
2) Generate a string like abbcccddddeeeee
So if n = 3, then return
'abbccc'
And if n = 5, then return
'abbcccddddeeeee'
Fundamental concept on string related problems in MATLAB:
https://www.youtube.com/watch?v=ikzmU...
CODE:
Fro printing integer sequence:
clc
x=input('Enter the number');
Y=[];
for i=1:x m=i; for i=1:m Y=[Y m]; end
end
disp(Y)
For printing character sequence:
clc
x=input('Enter the number');
m=97;
Y=[];
Y=[Y m];
for i=1:x-1 m=(97+i); for i=97:m Y=[Y m]; end
end
a=char(Y);
disp(a)
Generate a vector like 1,2,2,3,3,3,4,4,4,4 & abbcccddddeeeee camera iphone 8 plus apk | |
1 Likes | 1 Dislikes |
23 views views | 1.03K followers |
Science & Technology | Upload TimePublished on 6 Jun 2019 |
Không có nhận xét nào:
Đăng nhận xét