Introductory Computer Science - MATIB HW10 P1. Write a detailed MATLAI3 program
ID: 645452 • Letter: I
Question
Introductory Computer Science - MATIB HW10 P1. Write a detailed MATLAI3 program with several functions (main, local, nested...etc) with input parameters in script named p1.m that: a. Randomly generates two vectors vA and vB with the same size N (N geq 1). b. Calculates the average aveA and aveB of vA and VB. c. Calculates how many elements of vA are above ol aveA. d. Calculates how many elements of vB are above of aveB. e. Calculates how many elements of vector vA are greater than the respective elements (with the same indexes). f. Calculates the indexes i, I in [p q] for which [vAL[i] vB[i]|is maximum. Input data: N, p, and q. All input data are integers. Your program shoyld consist of several m files - one script and several functions A function that solves the subproblem a. A function that solves the subproblems b., c., and d., A function that solves the subproblem e., A function that solves the subproblem f., In a script tile, enter input data, input(N =), input(p = ), input(q = ); , call the functions to solve the subproblems and output all the results You have to decide what kind of function are the most appropriate for the program main and local; nested; others). Don't forget to: ? Document your program (functions, variables, important program segments) ? Test your program with variety of input data, copy and paste all the results that are produced from the execution of your program.Explanation / Answer
% Sample Program to find the Average %
vA=input('enter the value of x:');
vB=input('enter the value of h:');
L=max(length(vA),length(vB));
aveA=mean(vA,L);
aveB=mean(vB,L);
disp(aveA)
disp(aveB)
_________________________________________________________
sum=0; count=0;
for i=1:512
for j=1:512
if (A(i,j)>=11)
sum=sum+A(i,j);
count=count+1;
end
end
end
disp('Number of pixels grater than or equal to 11')
disp(count)
disp('sum')
disp(sum)
disp('Average')
Avrg=sum/count;
disp(Avrg)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.