Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started