Generating random 50 number between 0 to 27 and padding 000 all side?

 Accepted Answer

a=randi([0 27],1,50)
padarray(a,[1,1],0) % requires image processing toolbox

6 Comments

if i want padding 3 zero form all side in need:
a=randi([0 27],1,50)
padarray(a,[3,3],0)
its true?
Yes correct , make sure to accept the answer if it helped.
This answer not correct.
if a=[ 1 2 3 4 5 6 7]
after the padding it will be:
[ 0 0 0 1 0 0 0 2 0 0 0 3 0 0 0 4....]
how i do this?
ok try this:
a=[ 1 2 3 4 5 6 7];
b=zeros(1,numel(a)*3+numel(a));
b(4:4:end)=a(:)
command window:
b =
Columns 1 through 13
0 0 0 1 0 0 0 2 0 0 0 3 0
Columns 14 through 26
0 0 4 0 0 0 5 0 0 0 6 0 0
Columns 27 through 28
0 7
thank you!!!
But if i search for an odd number?
how i do this?
Anytime :) , that wasn't the original question so post a separate question.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!