Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

performing certain operation from a set a certain set of values

조회 수: 2 (최근 30일)
kash
kash 2011년 12월 28일
마감: MATLAB Answer Bot 2021년 8월 20일
i have dataset of 80 numbers=[1:1:80]
now i want to take first 8 values ,multiply each value by 2 and divide each by 2,so i will have 8 values each for multiplication and division,and then want to find average for that multilaction values and division values,same way i eant to perform for those 80 values from 1st 8,2nd 8,3rd 8........10th8 please help

답변 (1개)

Andrei Caragea
Andrei Caragea 2011년 12월 28일
Mathematically speaking, you can compute the average on the initial set of values and then multiply it/ divide it by 2. If you want to do this in a nice "visual" way, you can do the following: A=[1:80]; B=reshape(A,8,10).'; 2*sum(B,2)*1/8 for the multiplication avg and 1/2*sum(B,2)*1/8 for the division. Reshape turns A into a 10 by 8 matrix( 10 rows of 8 values) as you suggest and then you can do the summation and the average.
  댓글 수: 2
kash
kash 2011년 12월 28일
but Andrei a need for whole dataset,i need to use for loop.
Walter Roberson
Walter Roberson 2011년 12월 28일
You do not need a for loop to apply the techniques Andrei describes.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by