function [ ] = Vvarplot(axis,graph,varargin) %USE ON STUCK BEAD DATA %Input varargin in the form "data1,pwr1,data2,pwr2,..." %graph input is either the string 'same' or the string 'diff' %axis refers to whether you want to plot voltage in the x or y directions %for x direction input the string 'x' %for y direction input the string 'y' %'same' means that the created plots will be shown in the same window, but %serperate graphs %'diff' means that the created plots will be shown on seperate windows %When using 'same', you cannot input more than 4 datasets(change the %subplot command if you want more) for i = 2:2:length(varargin) pwr(i/2)=cell2mat(varargin(i)); end col = 'rgbcmyk'; % The 'color' string: each letter specifies a unique color % for the plot (i.e. col(5) = 'm' --> magenta) hold on for i = 1:2:length(varargin) if strcmp(graph,'diff') %Use if you want graphs on seperate windows figure(i) elseif strcmp(graph,'same') %use above if you want seperate graphs on the same window subplot(2,2,(i+1)/2) else disp('wrong input format') end %make the graphs data = cell2mat(varargin(i)); %Required statement to convert to matrix if strcmp(axis,'y') plot(data(:,1), data(:,3), col(mod((i-1)/2,7)+1)); elseif strcmp(axis,'x') plot(data(:,1), data(:,2), col(mod((i-1)/2,7)+1)); else disp('wrong input format') end ylabel('Voltage(Volts)') xlabel('Sample number') title('Voltage read from QPD while Scanning w/ the Optical Laser') legend(sprintf('Power = %5g',pwr((i+1)/2))) end end