%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  

%% TOPIC
% How to use symbolic variables in MATLAB using inline function
%% SUMMARY
% Language : Matlab 2008a; 
% Authors : Sri Harsha Garapati, Daniel Miller, Autar Kaw; 
% Mfile available at
% http://numericalmethods.eng.usf.edu/blog/symbolic_inline_blog.m; 
% Last Revised : January 17, 2012; 
% Abstract: This program shows how use symbolic variables using inline function.
clc
clear all

%% INTRODUCTION

disp('ABSTRACT')
disp('   This program shows you to use symbolic variables in MATLAB using inline')

disp(' ')
disp('AUTHOR')
disp('   Sri Harsha Garapati, Daniel Miller and')
disp('Autar K Kaw of http://autarkaw.wordpress.com')
disp(' ')
disp('MFILE SOURCE')
disp('   http://numericalmethods.eng.usf.edu/blog/symbolic_inline_blog.m')
disp(' ')
disp('LAST REVISED')
disp('   January 17, 2012')
disp(' ')

%% INPUTS

% Function Y
y   =inline('t^2+7*t+9');
% find the value of y(a) using the inline notation
% a=4
a=4;


%% DISPLAYING INPUTS

disp('INPUTS')
disp('function, Y=')
disp(y)
fprintf(' The input value of a is %g\n', a)
%% THE CODE

% find the value of y(a) using the inline notation
ya=y(a);

yeqn=char(y);  %char will convert the equation to a string
%% DISPLAYING OUTPUTS
disp('  ')
disp('OUTPUTS')
fprintf('  The function is: y(t)=%s\n',yeqn)
fprintf('  y(%g)=%g\n\n',a,ya)