CADJ shifts a vector so that the starting value is always the smallest value. CADJ shifts the input vector preserving the order in the vector. The function ensures that the smallest value is always the first element. USAGE: vout=cadj(vin); [vout,xout]=cadj(vin,xin); xout is an adjusted version of xin according to the adjustment of vin and vout INPUTS: vin: input vector xin: optional x coordinate vector OUTPUTS: vout: adjusted output vector xout: adjusted x coordinate vector
0001 function [vout,xout]=cadj(vin,xin) 0002 % CADJ shifts a vector so that the starting value is always the smallest value. 0003 % 0004 % CADJ shifts the input vector preserving the order in the vector. The 0005 % function ensures that the smallest value is always the first element. 0006 % 0007 % USAGE: 0008 % vout=cadj(vin); 0009 % 0010 % [vout,xout]=cadj(vin,xin); xout is an adjusted version of xin 0011 % according to the adjustment of vin and vout 0012 % 0013 % INPUTS: 0014 % vin: input vector 0015 % 0016 % xin: optional x coordinate vector 0017 % 0018 % OUTPUTS: 0019 % vout: adjusted output vector 0020 % 0021 % xout: adjusted x coordinate vector 0022 0023 [va,loc]=min(vin); 0024 vout=[vin(loc:length(vin)),vin(1:loc-1)]; 0025 if nargin>1 0026 xout=[xin(loc:length(xin)),xin(1:loc-1)]; 0027 end