Question

How to compute in matlab the mean only on the numbers that are greater than 0.5...

How to compute in matlab the mean only on the numbers that are greater than 0.5 by old-school style, with for and if loops.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code


count=0;
sum=0.0;
n=input('enter n'); %read n
disp("enter n number");
for i = 1:n % loop through n numbers
x=input('');
% check for number greater than 0.5
if x > 0.5
sum+=x; %summing
count+=1; %incrementing count
end
end
% calculate average
avg=sum/count;
disp("average is")
disp(avg);
  

screenshot

sample output

please upvote if it helped

Add a comment
Know the answer?
Add Answer to:
How to compute in matlab the mean only on the numbers that are greater than 0.5...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT