%Copy right Zambri 2014
%These codes created to illustrate inserting an eps figure into a LaTeX
%document and make use of psfrag package

clear all
clc
close all

figure(2)

%subplotting
sub(1)=subplot(1,2,1);
gca1=gca;
sub(2)=subplot(1,2,2);
gca2=gca;

set(gcf,'Position',[200   100   800   250]);

x=0:0.05:1;
y=sin(2*x*pi);
y1=sin(2*x*pi-1);

subplot(sub(1))
plot(x,y1,'k-^')

subplot(sub(2))
plot(x,y,'r-o')
hold on
plot(x,y1,'k-^')

%create a simple string/character anywhere in the plot 
Text1=annotation('textbox',[0.15 0.15 0.90 0.1]);
set(Text1,'String','(b)','FontSize',10);
set(Text1,'HorizontalAlignment','Center')
set(Text1,'VerticalAlignment','Middle')
set(Text1,'BackgroundColor','none')
set(Text1,'EdgeColor','none')

subplot(sub(1))
%Give a simple string/character to plot which will be recognize by LaTeX
%distributor
Y= ylabel('YY','rot',0);
pos = get(Y,'Position');
pos(1)=pos(1)-0.1;
set(Y,'Position',pos);

%conditioning before saving
gcfpos = get(gcf,'Position');
set(gcf,'Paperposition',gcfpos./100);

%saving into a folder call 'Fig', or basically anywhere you want
cd Fig

%saving plot
print -deps -r300 myfig.eps

%So I guess, your job now is to create 1) horizontal latel, need to fix the
%height of the plot, 2) Insert text (a), and (3) Show in LaTeX these new
%labels


