% function_plot.m clear; clc %% input data N=input('Enter the number of points: N = '); % { a=input('Enter the left endpoint of the interval: a = '); b=input('Enter the right endpoint of the interval: b = '); %} %ab=input('Enter the two endpoints of the interval: [a b] = '); a=min(ab); b=max(ab); %% fstr=input('Enter the function to be evaluated: f(t) = ','s'); pf=['@(t)' fstr]; pf=str2func(pf); % construct function handle from character vector %% display x=linspace(a,b,N)'; y=pf(x); figure(1); clf plot(x,y) set(gca,'FontSize',14) xlabel('x'); ylabel('y') title(['Plotted function: f(t) = ' fstr],'FontWeight','normal')