The following function can be used to restrict the range of
The following function can be used to restrict the range of a mathematical function: trim (f: : Function; cutoff=10) = x rightarrow abs (f(x)) > cutoff ? NaN : f(x) Try plotting trim (f) = (x^2 - 2x + 1) / (x^2 - 4) over [-5, 5]. What do you see as compared to the prvious graph of f(x)? The linespace (a, b) command creats (by default) 100 evenly spaced values between a and b. This is a useful set of values to use when plotting using the lower-level commands. Write a simple command to produce 100 values between 0 and 2n Write a simple command to produce 100 evenly-spaced values between 1/10 and 10. If a = [1,2,3,4,5] find a^-3 for each values (Use the map function.) The command xs = linespace (0, 10pi) creates a 100 points between 0 and 10pi. Map the function f(x) = cos^2(x^1/2) to these values. Write your commands here:
Solution
1.1)
The graph has the max value or the cutoff value equal to 10, hence the places where abs(f(x)) > 10, it will given NaN (not defined value) and at other points it will plot the f(x) curve as previous
1.2)
linspace in matlab has two variants, i.e. linspace(a,b) where it will generate 100 points between a and b
First command
linspace(0,2n)
Second command use the second variant for linspace
linspace(x1,x2,n) will generate n points, the space between n points will be equal to (x2-x1)/(n-1)
linspace(0.1,10,100)
the spacing between consecutive point will be equal to
(10-0.1)/100 = 9.9/100 = 0.099
