How to apply the same function on different rows of a vector?

조회 수: 3 (최근 30일)
Andrea Di Lelio
Andrea Di Lelio 2019년 8월 31일
댓글: waqas 2019년 8월 31일
Hello everyone,
I'm trying to apply a simple function to different rows of a vector 521x1. I want to divide the row 521 for 100 and then do the same for the row 501, 481, 461...basically every 20 rows I need to apply this division. At the end I expect to obtain a vector 26x1.
Could someone help me?
Thank you

채택된 답변

waqas
waqas 2019년 8월 31일
If I got the question right, this is how it should work:
andr = randn(521,1)
andrn = 1/100*andr(521:-20:1) % you can use 1/100.*(andr(521:-20:1,:)) in case there are more columns
The code will give the last value (on 521st row) first as you mentioned in the question.
  댓글 수: 2
Andrea Di Lelio
Andrea Di Lelio 2019년 8월 31일
It is perfect, thank you very much.
waqas
waqas 2019년 8월 31일
Great. If it does the job then accept the answer :)

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

추가 답변 (0개)

카테고리

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