%% 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
%% SUMMARY
% Language : Matlab 2008a; 
% Authors : Sri Harsha Garapati, Daniel Miller, Autar Kaw; 
% Mfile available at
% http://numericalmethods.eng.usf.edu/blog/symbolicops_blog.m; 
% Last Revised : January 17, 2012; 
% Abstract: This program shows how use symbolic variables.
clc
clear all

%% INTRODUCTION

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

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/symbolicops_blog.m')
disp(' ')
disp('LAST REVISED')
disp('   January 17, 2012')
disp(' ')

%% INPUTS

syms t r s    % t r and s are now symbolic varibles
a  =t^2+r;
y  =t^3+a+s;

%% DISPLAYING INPUTS

disp('INPUTS')
disp('a=')
disp(a)
disp('y=')
disp(y)
%% THE CODE
eqn=char(y);  %char will convert the equation to a string
%% DISPLAYING OUTPUTS
disp('  ')
disp('OUTPUTS')
fprintf('  The symbolic equation is\n  %s\n\n',eqn)