Hello I wanted to ask if I have a row vector and I want to medofy each element of the vector in such way that element 1 is equal to (element 1 *0), and element2= (element2*1) and element3= (element3*2) and so on. is possible to implement this is matlab? do I need a loop?

 채택된 답변

David Hill
David Hill 2020년 8월 13일

0 개 추천

yourVector.*(0:length(yourVector)-1);

댓글 수: 3

I am getting an error. is lenght here is number of elements in that vector?
You should not be getting any errors. If you cut and paste this into your command prompt, you are getting an error?
yourVector=1:10;
newVector=yourVector.*(0:length(yourVector)-1);
thank you.

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

추가 답변 (1개)

madhan ravi
madhan ravi 2020년 8월 13일

0 개 추천

vector(:) .*(0:numel(vector(:)) - 1)

댓글 수: 1

madhan ravi
madhan ravi 2020년 8월 13일
Are you trying to finish your homework by making others do it? Start with MATLAB On-ramp.

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

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2020년 8월 13일

댓글:

2020년 8월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by