필터 지우기
필터 지우기

Create a vector in Matlab

조회 수: 1 (최근 30일)
klipya
klipya 2012년 8월 2일
Hi
I have a question. I've a number in one variable called x, for example, 0.9. I need to create a vector in Matlab with 2500 positions and, in the positions 250 to 360, to copy that number and the rest of the numbers, with 0. How can I code it?
It's something like this:
0
0
0
0
0
0
0
0.9 (in the position 250)
0.9
0.9
...
0.9 (in the position 360)
0
0
0
0 (since 2500)

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 8월 2일
simple example:
I = zeros(1,10)
i1 = 5
i2=7
I(i1:i2) = .9
  댓글 수: 1
klipya
klipya 2012년 8월 2일
Thank you so much!

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

추가 답변 (1개)

Alexander
Alexander 2012년 8월 2일
A=zeros(2500,1);
A(250:360)=x;
  댓글 수: 1
klipya
klipya 2012년 8월 2일
Thanks you a lot! It works perfectly! ;)

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by