Problem Statement
Write a function plot2fnhand that will receive two function handles as input arguments, and will display in two Figure Windows, plots of these functions with the function names in the titles.
The function will create an x vector that ranges from 1 to n (where n is a random integer in the inclusive range from 4 to 10).
Example Call
>> prob7_plot2fnhand(@sqrt, @exp)
If the random integer is 5, the first Figure Window would display the sqrt function of x = 1:5, and the second Figure Window would display exp(x) for x = 1:5.
function prob7_plot2fnhand(fh1, fh2)
%{
Problem
23. Write a function plot2fnhand that will receive two function handles as input
arguments, and will display in two Figure Windows, plots of these functions with
the function names in the titles. The function will create an x vector that ranges
from 1 to n (where n is a random integer in the inclusive range from 4 to 10).
For example, if the function is called as follows
>> prob7_plot2fnhand(@sqrt, @exp)
and the random integer is 5, the first Figure Window would display the sqrt
function of x =1:5,and thesecondFigureWindowwould display exp(x) for x =1:5.
%}
N = randi([4 10]);
x = [1:N];
y1 = fh1(x);
y2 = fh2(x);
figure(1); clf;
plot(x,y1);
title( func2str(fh1) );
figure(2); clf;
plot(x,y2)
title( func2str(fh2) );
Expected Output (when n=5):
Figure 1: Plot of sqrt(x) for x = [1, 2, 3, 4, 5]
y1 = [1.0000, 1.4142, 1.7321, 2.0000, 2.2361]
Figure 2: Plot of exp(x) for x = [1, 2, 3, 4, 5]
y2 = [2.7183, 7.3891, 20.0855, 54.5982, 148.4132]