help with this question
이전 댓글 표시
Hi, so I am trying to geta function that returns an output, which is the square root of the mean of the squares of the first nn positive odd integers, where nn is a positive integer and the only input argument. for example if nn=3 i want my function to return the sqaure root of the average of the numbers 1 9, and 25. my code so far is this:
function orms = odd_rms(nn)
orms = sqrt(mean((1:nn).^2));
however this is only returning positive integers. So I am wondering how to make this odd positive integers.
댓글 수: 1
prashant paudel
2018년 5월 23일
function rms=odd_rms(n) x=n*(2*n+1)*(2*n-1)/3; rms=sqrt(x/n);
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2016년 8월 6일
nn=3
mm=(0:nn-1)*2+1
카테고리
도움말 센터 및 File Exchange에서 Signal Generation, Analysis, and Preprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!