array [10x8]

2 views (last 30 days)
bala k
bala k on 19 Apr 2011
G(1,:)=[ 1 2 3 8 5 6 3 5];
for j = 1:10,
for i = 1:8,
n(j,i)=G(1,8);
end
end
i need to calculate 10 rows and 8 columns, G value is = [ 1 2 3 8 5 6 3 5];
i couldn't get the G value in 10 rows.

Accepted Answer

Jan
Jan on 19 Apr 2011
G = [ 1 2 3 8 5 6 3 5];
n = repmat(G, 10, 1)
or
n = G(ones(1, 10), :);
  2 Comments
bala k
bala k on 19 Apr 2011
sir, if the G value is change in each row. how to i change the code.
Walter Roberson
Walter Roberson on 19 Apr 2011
for j = 1:10,
for i = 1:8,
n(j,i)=G(1,i);
end
end

Sign in to comment.

More Answers (0)

Categories

Find more on Data Types in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!