Jonathan Dreyer




Matlab Examples

 

Plot with different y-axis

close all; clear all

x=[0:0.1:10];
y1=exp(x)./x.^2;
y2=10*cos(x);
%plot(x,y1)
PlotFontSize=10;

[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
set(gca,'box','off')
set(get(AX(1),'Ylabel'),'String','Voltage (V)','FontName',...
'Times New Roman','FontSize', PlotFontSize, 'Color','k')
set(get(AX(1),'Xlabel'),'String','Time (sec)','FontName',...
'Times New Roman','FontSize', PlotFontSize, 'Color','k')
set(get(AX(2),'Ylabel'),'String','Current (A)','FontName',...
'Times New Roman','FontSize', PlotFontSize, 'Color', 'b')

set(AX(1),'FontName','Times New Roman','FontSize',PlotFontSize,...
'YScale', 'log', 'YLim', [0.05 400], 'YTick',[0.1; 1; 10;100])
set(AX(1),'YTickLabel',num2str(get(AX(1),'YTick').'), 'YColor','k')

set(AX(2),'FontName','Times New Roman','FontSize',PlotFontSize,...
'YScale', 'linear', 'YColor', 'b', 'YTick',[-10; -5; 0; 5; 10])

hLegend=legend('Dectector Voltage','Current');
set(hLegend,'Location','NorthWest')

set(H1,'LineWidth',1, 'Color','k')
set(H2,'LineWidth',1, 'Color','b')

 


 

 

 

 

 

 

(c) jdreyer 2012