필터 지우기
필터 지우기

make single element be array,,

조회 수: 30 (최근 30일)
baby
baby 2012년 5월 12일
hello,,
i m new beginner in matlab,,
so i still have little experience,,
i want to ask about how to make single element be array,,
example i have variable called w1 = 1;
and i want make array of w1 like w1 = [1 1 1 1 1]
please help me,,

채택된 답변

per isakson
per isakson 2012년 5월 12일
This used to be called Tonys trick:
w1 = w1( ones( 1, 5 ) );
this is more standard
w1 = repmat( w1, 1, 5 );
PS. There is a good Getting Started!
--- Edit ---
>> w1=-0.5
w1 =
-0.5000
>> w1( ones( 1, 5 ) )
ans =
-0.5000 -0.5000 -0.5000 -0.5000 -0.5000
You need to experiment!
>> repmat( -0.11, 1, 5 )
ans =
-0.1100 -0.1100 -0.1100 -0.1100 -0.1100
  댓글 수: 1
baby
baby 2012년 5월 12일
thank you :)

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

추가 답변 (1개)

baby
baby 2012년 5월 12일
But how if i want convert another number like w1 = -0.5 be w1 = [-0.5 -0.5 -0.5 -0.5 -0.5]?

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by