create a matrix!

Hello I have
row=[1 2];
col=[10 11 13 ];
I want to have b=[10 11 13; 10 11 13]
How can i do that?

1 个评论

Please do not Tag specific individuals for a question, as it puts pressure on the named person to answer.

请先登录,再进行评论。

 采纳的回答

repmat(col,2,1)
or
repmat(col,numel(row),1)

4 个评论

but it does not work for other row and col: Please consider example below:
row=[1 2 3 4 5 6 7];
col=[ 537 538];
And I want b=[ 537 538; 537 538; 537 538; 537 538; 537 538; 537 538; 537 538]
can you please again help me?
I updated the answer. What you really need is 7 rows.
It works now. I have some little matrices with different size (such as 7*3, 2*5, 8*1,...) and I need to put them in a bigger matrix. My problem actually is I want similar arrays with similar row or col is put in the same position (array) in the bigger matrix. It actually have taken a lot of time until now and no matter how much I have spent on it, It still does not work!
You may want to start a new thread and explain the issue. I'm sure someone here can help.

请先登录,再进行评论。

更多回答(1 个)

Ryan
Ryan 2012-6-1
row = [1 2];
col = [10 11 13];
b = ones(length(row),length(col));
clear m
for m = 1:length(row)
b(m,:) = col;
end

类别

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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by