Working on assignment in matlab and am very confused any hel
Working on assignment in matlab and am very confused, any help would be appreciated
P1: Finding the lowest neighbors The ‘.mat’ file elevation.mat contains the elevation data. load elevation.mat to get the variable map, which is a matrix of heights in meters for a region near Heber City, Utah. You also get a small matrix test that is 10x10. Create a new figure (figure number 1) and display the map as a shaded image with imagesc(map); axis equal; colormap gray; Give this figure the title ‘height map’. Note: The statement [r,c] = size(map); assigns r and c to the numbers of rows and columns. If you use r and c instead of the numbers, then you can run your code on other size maps without modification. Every pixel P that is not on the boundary of the image has eight neighbors. Water follows the path of steepest descent, so we would like to know, for each non-boundary pixel, direction to the lowest height of the 9 cells around P, including P itself. One way to do that is to store both row and column offsets for each map point r,c to the neighbor: we can record these offsets in two matrices, each containing only the numbers -1, 0, and +1. Let\'s define boundary pixels to have both offsets zero. Thus, write and turn in a function [roffset, coffset] = findLowNhbr(map) that returns two matrices of the same size as map, so that pixel map(r,c) has pixel map(r+roffset(r,c), c+coffset(r,c)) as the minimum of these 9 heights. (You do not need to crea
Solution
clear
for k=0:70
x(k+1)=0.1*k; % Indices of vectors must be NON-ZERO!
sum = 0;
for m=0:10
sum = sum+(x(k+1)^m)/gamma(m+1); % Approx exp(x) using its Taylor series
end
e(k+1) = sum; % e(k+1) contains the Taylor series approx. for x=x(k+1);
end
semilogy(x,e)
title(\'Approximation of e^x for x between 0 and 7\')
xlabel(\'x\')
ylabel(\'e^x\')
