

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for writing two functions in matlab: aprime(m) to check if a number is prime, and lasttwinpair(n) to find the last twin prime pair smaller than or equal to a given number n. The document also includes a brief explanation of vectors and how to access their components.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CS100M Section Exercise 5
%Given vector v, print its values for k= 1:length(v) fprintf(’%d ’, v(k)) end fprintf(’\n’)
Complete the following function. The only built-in function that you can use is length.
function [val, ind] = myMin(v) % val is the minimum value in vector v. % ind is the position of the first occurence of val in v.