array [10x8]

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.

 采纳的回答

Jan
Jan 2011-4-19

1 个投票

G = [ 1 2 3 8 5 6 3 5];
n = repmat(G, 10, 1)
or
n = G(ones(1, 10), :);

2 个评论

bala k
bala k 2011-4-19
sir, if the G value is change in each row. how to i change the code.
for j = 1:10,
for i = 1:8,
n(j,i)=G(1,i);
end
end

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by