Assume the following numbers in a table
1
2
3
4
How can I multiply them in the following manner:
1
1
1
1
2
2
2
2
3
3
3
3
4
4
4
4
thanks

댓글 수: 1

John D'Errico
John D'Errico 2014년 11월 14일
You mean to replicate them, not multiply them. Multiplication is an arithmetic operation as I recall.

댓글을 달려면 로그인하십시오.

 채택된 답변

per isakson
per isakson 2014년 11월 14일

1 개 추천

Try
x = [1;2;3;4];
reshape( repmat( transpose(x), [4,1]), [], 1 )

추가 답변 (3개)

Matt J
Matt J 2014년 11월 14일

1 개 추천

Another way,
x = [1;2;3;4];
result = x( ceil((1:length(x)*4)/4) );
Matt J
Matt J 2014년 11월 14일

1 개 추천

kron([1;2;3;4], ones(4,1))
Matt J
Matt J 2014년 11월 14일

1 개 추천

x=1:4;
result=ones(4,1)*x;
result=result(:);

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

질문:

AA
2014년 11월 14일

답변:

2014년 11월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by