Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function that takes a vector as input and returns the average of all the positive numbers that are multiples of 7 My current

Write a function that takes a vector as input and returns the average of all the positive numbers that are multiples of 7

My current code is

function avg = avgpositive7multiples_for(x);

positive = x(x>=0);

y = sum(positive(find(mod(positive, 7)==0)));

a = numel(find((mod(positive, 7)==0)));

avg = y/a;

but i have to use a for loop for this problem and I am unsure of how to convert it

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

=+b) What is the standard deviation of the sample range?

Answered: 1 week ago