Tutorial 1 solution

Tutorial 1 solution - FormatforAnonymousFunctions...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Format for Anonymous Functions f = @(x) expression in x g = @(u, v) expression in u and v Activity 1 1. On a piece of paper, write the code that will create these vectorized functions: ݂ሺݔሻൌ ݁ sinሺߨݔ ൅ >> f=@(x) exp(x.^2).*sin(pi.*x + pi./2) ݃ሺݑ,ݒሻ ൌ 1000݁ ିሺ௨ ା௩ >> g=@(u,v) 1000.*exp(–(u.^2 + v.^2)) 2. Trade papers with someone and input their code to see if it works. Test their code using these values (where you can easily determine the expected answers): a. f(0) = 1 b. f(1) = 2.71828 c. f(–0.5) = 0 d. f([0, 1, –0.5]) = [ 1, 2.71828, 0 ] e. g(0, 0) = 1000 f. g(1, 0) = g(0, 1) = g(–1, 0) = g(0, –1) = 367.8794 Activity 3 Sphere Dist uses latitude and longitude in decimals. Latitude and longitude can also be given in degrees, minutes, seconds. For example:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online