Question: 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
Get step-by-step solutions from verified subject matter experts
