2 Create a matlab function that calculates x for a specified
     2. Create a matlab function that calculates x for a specified x and no. Write a matlab script that uses this function to graph x, y-x2, y x3, y on the same graph  
  
  Solution
%function to compute x^n
 function [result] = power(x, n)
 result = x.^n;
 end
%array of 10 elements for plotting
 x = [1 2 3 4 5 6 7 8 9 10];
%use power function to compute Y\'s
 y1 = power(x,1)
 y2 = power(x,2)
 y3 = power(x,3)
 y4 = power(x,4)
%plot the figure
 figure
 subplot(2,2,1)   
 plot(x,y1)   
 title(\'Linear\')
subplot(2,2,2)   
 plot(x,y2)
 title(\'Quadratic\')
subplot(2,2,3)   
 plot(x,y3)   
 title(\'Cubic\')
subplot(2,2,4)
 plot(x,y4)
 title(\'X ^ 4\')

