Programming Exam Notes
Programming Exam Notes BE1500
Popular in Intro to Programming
verified elite notetaker
Popular in Engineering and Tech
This 4 page Study Guide was uploaded by Neha Bhagirath on Saturday July 9, 2016. The Study Guide belongs to BE1500 at Wayne State University taught by Tonya Whitehead in Spring 2016. Since its upload, it has received 19 views. For similar materials see Intro to Programming in Engineering and Tech at Wayne State University.
Reviews for Programming Exam Notes
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 07/09/16
EXAM REVIEW: function[sum]=E2RP2(M) r=1; c=1; sum=0; [rows,cols]=size(M); while r<=rows %rows is the determined number of rows, r is the counter for the number of rows while c<=cols i mod(r,2)==1 %when you give a variable a value, it has one equal sign. when giving a condition it has two equal signs N(r,c)=M(r,c)^(1/3) else N(r,c)=M(r,c)^(1/2) end sum=sum+N(r,c) %N is the new matrix, adding up all the values here c=c+1; nd end r=r+1;%increment the other counter c=1; %reset the c values or it will only take the last column value (have to reset the value for the inner loop before you reset your outer loop in nested loops.) %i reaches the max number of rows and has to go to the next line for the %rows again, so you must reset it because the inner loop will stop %otherwise end Command Window: K>> E2RP2([2,3,4;3,4,5;3,4,5]) N = 1.2599 sum = 1.2599 N = 1.2599 1.4422 sum = 2.7022 N = 1.2599 1.4422 1.5874 sum = 4.2896 Answer to #3) sum=0; n=1; %define n above the while loop. could also use 0 while n<=1000 sum=(isprime(n)*n+sum); %we multiply by n because this is another option. isprime(n) will be 1 or 0, and if you have 1, %you will multiply by n, the actual number, and add it on, instead of adding a 1 or a 0 n=n+1 n has to change in the loop end OR sum=0; forn=1:1000 i isprime(n)==1 sum=n+sum %sum adds values nd end Answer to #4) functi [ max,min ] = Practice( M ) [rows,cols]=size(M); max=M(1,1%setting the smallest and biggest number in our matrix as the max and min. Could do inf to +inf as well min=M(1,1); for r=1:rows or c=1:cols i max<M(r,c) max=M(r,c) end i min>M(r,c) min=M(r,c) end end
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'