필터 지우기
필터 지우기

Replacing the contents of a matrix

조회 수: 1 (최근 30일)
Dubstep Dublin
Dubstep Dublin 2016년 1월 30일
댓글: Star Strider 2016년 1월 30일
I have a 1 dimensional matrix (1000 x 1) that consists of numbers from 0 to 63.
I would like to replace the contents of this matrix as follows:
0 --> 0
1 --> 0.5
2 --> 1
3 --> 1.5
and so on..
Can someone please show me how to do this.
Thanks

채택된 답변

Star Strider
Star Strider 2016년 1월 30일
It looks as though you’re just dividing every element by 2, and rounding to one decimal place.
Letting ‘v’ define your vector, this works:
Out = fix(5*v)/10;
  댓글 수: 2
Dubstep Dublin
Dubstep Dublin 2016년 1월 30일
It works! Thanks a lot.
Star Strider
Star Strider 2016년 1월 30일
My pleasure!

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 1월 30일
v=[0 1 2 3 4 5]'
out=v*0.5

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by