- Timestamp:
- Jan 30, 2015, 8:37:03 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_motion.m
r859 r862 232 232 if test_piv 233 233 [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2))); 234 if (isfield(hhciv,'TestCiv2')&& get(hhciv.TestCiv2,'Value'))% if TestCiv2 is activated 234 if isfield(hhciv,'TestCiv2') && strcmp(get(hhciv.Civ2,'Visible'),'on')&& ... 235 strcmp(get(hhciv.TestCiv2,'Visible'),'on')&& get(hhciv.TestCiv2,'Value')% if TestCiv2 is activated 235 236 CivOption='Civ2'; 236 237 Param.CheckCiv1=0; 237 238 par_civ=read_GUI(hhciv.Civ2);%read the Civ2 panel in civ_input 238 par_civ.Civ1_SubRange=Field.Civ1_SubRange; 239 par_civ.Civ1_NbCentres=Field.Civ1_NbCentres; 240 par_civ.Civ1_Coord_tps=Field.Civ1_Coord_tps; 241 par_civ.Civ1_U_tps=Field.Civ1_U_tps; 242 par_civ.Civ1_V_tps=Field.Civ1_V_tps; 239 par_civ.Civ1_SubRange=Field.Civ1_SubRange;% get the subranges used for patch 240 par_civ.Civ1_NbCentres=Field.Civ1_NbCentres;% get the nbre of civ1 data points in each subrange 241 par_civ.Civ1_Coord_tps=Field.Civ1_Coord_tps;% get the positions of the centres (Civ1 data) 242 par_civ.Civ1_U_tps=Field.Civ1_U_tps;% get the tps coefficients for spline, U component 243 par_civ.Civ1_V_tps=Field.Civ1_V_tps;% get the tps coefficients for spline, V component 243 244 par_civ.Civ1_Dt=Field.Civ1_Dt; 244 245 par_civ.Civ2_Dt=Field.Civ2_Dt; 245 shiftx=Field.ShiftX(ind_pt); 246 shiftx=Field.ShiftX(ind_pt);% get field info stored in the cuirrent figure 246 247 shifty=Field.ShiftY(ind_pt); 247 248 else … … 306 307 if ~isempty(corrfig) 307 308 set(0,'CurrentFigure',corrfig(1)) 308 AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]); 309 AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);% plot the correlation map, with full colormap from 0 to 1 309 310 AxeData.CurrentVector=line([0 Data.([CivOption '_U'])],[0 Data.([CivOption '_V'])],'Tag','vector'); 310 AxeData.TitleHandle=title( num2str(par_civ.Grid));311 AxeData.TitleHandle=title(['[x,y]= ' num2str(par_civ.Grid) ' px']); 311 312 colorbar 312 313 set(CurrentAxes,'UserData',AxeData) 313 set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal') 314 ParentAxe=get(AxeData.CurrentCorrImage,'parent'); 315 set(ParentAxe,'YDir','normal') 316 set(ParentAxe,'DataAspectRatio',[1 1 1]); %equal axis scale 314 317 end 315 318 else … … 317 320 set(AxeData.CurrentCorrImage,'XData',rangx) 318 321 set(AxeData.CurrentCorrImage,'YData',-rangy) 322 ParentAxe=get(AxeData.CurrentCorrImage,'parent'); 323 rangx(1)=min(rangx(1),0); 324 rangx(2)=max(rangx(2),0); 325 rangy(2)=max(rangy(2),0); 326 rangy(1)=min(rangy(1),0); 327 set(ParentAxe,'XLim',rangx) 328 set(ParentAxe,'YLim',[-rangy(2) -rangy(1)]) 319 329 set(AxeData.CurrentVector,'XData',[0 Data.([CivOption '_U'])],'YData',[0 Data.([CivOption '_V'])]); 320 set(AxeData.TitleHandle,'String', num2str(par_civ.Grid))330 set(AxeData.TitleHandle,'String',['[x,y]= ' num2str(par_civ.Grid) ' px']) 321 331 end 322 332 end -
trunk/src/series/civ2vel_3C.m
r840 r862 1 %'civ2vel_3C': combine velocity fields from two cameras to get three velocity components1 %'civ2vel_3C': combine velocity fields from two cameras to get three velocity components 2 2 %------------------------------------------------------------------------ 3 3 % function ParamOut=civ2vel_3C(Param) … … 116 116 tsaiA=XmlData{1}.GeometryCalib; 117 117 else 118 msgbox_uvmat('ERROR','no geometric calibration available for image A')118 disp_uvmat('ERROR','no geometric calibration available for image A',checkrun) 119 119 return 120 120 end … … 122 122 tsaiB=XmlData{2}.GeometryCalib; 123 123 else 124 msgbox_uvmat('ERROR','no geometric calibration available for image B')124 disp_uvmat('ERROR','no geometric calibration available for image B',checkrun) 125 125 return 126 126 end 127 127 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 128 128 129 %% grid of physical positions 129 %% grid of physical positions (given by projection plane) 130 if ~Param.CheckObject 131 disp_uvmat('ERROR','a projection plane with interpolation is needed',checkrun) 132 return 133 end 134 ObjectData=Param.ProjObject; 135 130 136 [x,y]=meshgrid(ObjectData.RangeX(1):ObjectData.DX:ObjectData.RangeX(2),ObjectData.RangeY(1):ObjectData.DY:ObjectData.RangeY(2)); 137 z=zeros(size(x)); 138 [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num) 131 139 %camera coordinates:initialisation 2 cameras 132 140 NbCamera=2; … … 178 186 %% transform the input field (e.g; phys) if requested (no transform involving two input fields) 179 187 %camera coordinates 180 xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1);181 yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2);182 zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tx_Ty_Tz(3);183 184 %undistorted image coordinates185 Xu=xc./zc;186 Yu=yc./zc;187 188 Data{iview}=phys(Data{iview},XmlData{iview}); 188 189 -
trunk/src/series/civ_input.m
r861 r862 397 397 %% Civ2 parameters 398 398 Param.Civ2.CorrBoxSize=[21 21]; 399 Param.Civ2.SearchBoxSize=[ 31 31];399 Param.Civ2.SearchBoxSize=[27 27]; 400 400 Param.Civ2.CorrSmooth=1; 401 401 Param.Civ2.Dx=10; … … 539 539 set(handles.ListPairCiv2,'Visible','off') 540 540 end 541 if max(checkbox(1:3))==0 && get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3 541 hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series' 542 hhseries=guidata(hseries); %handles of the elements in 'series' 543 InputTable=get(hhseries.InputTable,'Data'); 544 if size(InputTable,1)>=1 && strcmp(InputTable{1,5},'.nc') && max(checkbox(1:3))==0 %&& get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3 542 545 set(handles.CheckCiv3,'Visible','on') 543 546 else … … 573 576 checkeven=(mod(ActionInput.Civ2.CorrBoxSize,2)==0); 574 577 ActionInput.Civ2.CorrBoxSize(checkeven)=ActionInput.Civ2.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values 575 ActionInput.Civ2.SearchBoxSize=max(ActionInput.Civ2.SearchBoxSize,ActionInput.Civ2.CorrBoxSize+ 6);578 ActionInput.Civ2.SearchBoxSize=max(ActionInput.Civ2.SearchBoxSize,ActionInput.Civ2.CorrBoxSize+4); 576 579 checkeven=(mod(ActionInput.Civ2.SearchBoxSize,2)==0); 577 580 ActionInput.Civ2.SearchBoxSize(checkeven)=ActionInput.Civ2.SearchBoxSize(checkeven)+1;% set search box sizes to odd values … … 1132 1135 % --- Executes on button press in CheckDeformation. 1133 1136 function CheckDeformation_Callback(hObject, eventdata, handles) 1134 set(handles. configSource,'String','NEW')1137 set(handles.ConfigSource,'String','NEW') 1135 1138 set(handles.OK,'BackgroundColor',[1 0 1]) 1136 1139 … … 1751 1754 Param.Action.RUN=1; 1752 1755 Param.ActionInput=read_GUI(handles.civ_input); 1756 if isfield(Param.ActionInput,'Fix1') 1757 Param.ActionInput=rmfield(Param.ActionInput,'Fix1'); 1758 end 1759 if isfield(Param.ActionInput,'Patch1') 1760 Param.ActionInput=rmfield(Param.ActionInput,'Patch1'); 1761 end 1762 if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 1763 Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); 1764 end 1765 if isfield(Param.ActionInput,'Fix2') 1766 Param.ActionInput=rmfield(Param.ActionInput,'Fix2'); 1767 end 1768 if isfield(Param.ActionInput,'Patch2') 1769 Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); 1770 end 1753 1771 if isfield(Param,'OutputSubDir') 1754 1772 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series … … 1819 1837 Param.Action.RUN=1; 1820 1838 Param.ActionInput=read_GUI(handles.civ_input); 1839 if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 1840 Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); 1841 end 1842 if isfield(Param.ActionInput,'Fix2') 1843 Param.ActionInput=rmfield(Param.ActionInput,'Fix2'); 1844 end 1845 if isfield(Param.ActionInput,'Patch2') 1846 Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); 1847 end 1821 1848 if isfield(Param,'OutputSubDir') 1822 1849 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series … … 1928 1955 ViewData.PlotAxes.X=Data.Civ2_X'; 1929 1956 ViewData.PlotAxes.Y=Data.Civ2_Y'; 1930 ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by runningciv21957 ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by the preliminary run of civ2 1931 1958 ViewData.PlotAxes.ShiftY=Data.Civ2_V'; 1932 1959 ViewData.PlotAxes.Civ1_SubRange=Data.Civ1_SubRange; … … 2279 2306 drawnow 2280 2307 end 2281 2282 2283 2284 2285 2286 -
trunk/src/series/civ_series.m
r861 r862 614 614 end 615 615 end 616 if par_civ2.CheckDeformation617 DUDX=zeros(size(par_civ2.Grid,1),1);618 DUDY=zeros(size(par_civ2.Grid,1),1);619 DVDX=zeros(size(par_civ2.Grid,1),1);620 DVDY=zeros(size(par_civ2.Grid,1),1);621 end622 616 623 617 % get the guess from patch1 or patch2 (case 'CheckCiv3') … … 661 655 Shifty=zeros(size(par_civ2.Grid,1),1); 662 656 nbval=zeros(size(par_civ2.Grid,1),1);% nbre of interpolated values at each grid point (from the different patch subdomains) 657 if par_civ2.CheckDeformation 658 DUDX=zeros(size(par_civ2.Grid,1),1); 659 DUDY=zeros(size(par_civ2.Grid,1),1); 660 DVDX=zeros(size(par_civ2.Grid,1),1); 661 DVDY=zeros(size(par_civ2.Grid,1),1); 662 end 663 663 NbSubDomain=size(SubRange,3); 664 664 for isub=1:NbSubDomain% for each sub-domain of Patch1 665 665 nbvec_sub=NbCentres(isub);% nbre of Civ vectors in the subdomain 666 666 ind_sel=find(par_civ2.Grid(:,1)>=SubRange(1,1,isub) & par_civ2.Grid(:,1)<=SubRange(1,2,isub) &... 667 par_civ2.Grid(:,2)>=SubRange(2,1,isub) & par_civ2.Grid(:,2)<=SubRange(2,2,isub)); 667 par_civ2.Grid(:,2)>=SubRange(2,1,isub) & par_civ2.Grid(:,2)<=SubRange(2,2,isub));% grid points in the subdomain 668 668 if ~isempty(ind_sel) 669 epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites 669 epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites (measurement grids) 670 670 ctrs=Coord_tps(1:nbvec_sub,:,isub) ;%(=initial points) ctrs 671 671 nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for each interpolation point (in case of subdomain overlap) 672 EM = tps_eval(epoints,ctrs); 673 Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub); 672 EM = tps_eval(epoints,ctrs);% thin plate spline (tps) coefficient 673 Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub);%velocity shift estimated by tps from civ1 674 674 Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub); 675 675 if par_civ2.CheckDeformation … … 691 691 end 692 692 end 693 ibx2=ceil(par_civ2.CorrBoxSize(1)/2);694 iby2=ceil(par_civ2.CorrBoxSize(2)/2);695 par_civ2.SearchBoxSize(1)=2*ibx2+9;% search ara +-4 pixels around the guess696 par_civ2.SearchBoxSize(2)=2*iby2+9;693 % ibx2=ceil(par_civ2.CorrBoxSize(1)/2); 694 % iby2=ceil(par_civ2.CorrBoxSize(2)/2); 695 % par_civ2.SearchBoxSize(1)=2*ibx2+9;% search ara +-4 pixels around the guess 696 %par_civ2.SearchBoxSize(2)=2*iby2+9; 697 697 if CheckInputFile % else Dt given by par_civ2 698 698 if strcmp(Param.ActionInput.ListCompareMode,'displacement') … … 704 704 end 705 705 par_civ2.SearchBoxShift=(Civ2_Dt/Civ1_Dt)*[Shiftx(nbval>=1)./nbval(nbval>=1) Shifty(nbval>=1)./nbval(nbval>=1)]; 706 par_civ2.Grid=[par_civ2.Grid(nbval>=1,1)-par_civ2.SearchBoxShift(:,1)/2 par_civ2.Grid(nbval>=1,2)-par_civ2.SearchBoxShift(:,2)/2];% grid taken at the extrapolated origin of the displacement vectors 706 % shift the grid points by half the expected shift to provide the correlation box position in image A 707 par_civ2.Grid=[par_civ2.Grid(nbval>=1,1)-par_civ2.SearchBoxShift(nbval>=1,1)/2 par_civ2.Grid(nbval>=1,2)-par_civ2.SearchBoxShift(nbval>=1,2)/2]; 707 708 if par_civ2.CheckDeformation 708 709 par_civ2.DUDX=DUDX./nbval; … … 712 713 end 713 714 714 % calculate velocity data (y and v in i ndices, reverse to y component)715 % calculate velocity data (y and v in image indices, reverse to y component) 715 716 [xtable, ytable, utable, vtable, ctable, F,result_conv,errormsg] = civ (par_civ2); 716 717 … … 880 881 % .ImageWidth: nb of pixels of the image in x 881 882 % .Dx, Dy: mesh for the PIV calculation 882 % .Grid: grid giving the PIV calculation points (alternative to .Dx .Dy) 883 % .Grid: grid giving the PIV calculation points (alternative to .Dx .Dy): centres of the correlation boxes in Image A 883 884 % .Mask: name of a mask file or mask image matrix itself 884 885 % .MinIma: thresholds for image luminosity … … 893 894 894 895 %% prepare measurement grid 895 if isfield(par_civ,'Grid')% grid points set as input 896 if ischar(par_civ.Grid)%read the grid file if the input is a file name 896 if isfield(par_civ,'Grid')% grid points set as input, central positions of the sub-images in image A 897 if ischar(par_civ.Grid)%read the grid file if the input is a file name (grid in x, y image coordinates) 897 898 par_civ.Grid=dlmread(par_civ.Grid); 898 899 par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file) 899 900 end 900 % else par_civ.Grid is already an array 901 else% automatic grid 901 % else par_civ.Grid is already an array, no action here 902 else% automatic grid in x, y image coordinates 902 903 minix=floor(par_civ.Dx/2)-0.5; 903 904 maxix=minix+par_civ.Dx*floor((par_civ.ImageWidth-1)/par_civ.Dx); 904 miniy=floor(par_civ.Dy/2)-0.5; 905 miniy=floor(par_civ.Dy/2)-0.5;% first automatic grid point at half the mesh Dy 905 906 maxiy=minix+par_civ.Dy*floor((par_civ.ImageHeight-1)/par_civ.Dy); 906 907 [GridX,GridY]=meshgrid(minix:par_civ.Dx:maxix,miniy:par_civ.Dy:maxiy); 907 908 par_civ.Grid(:,1)=reshape(GridX,[],1); 908 par_civ.Grid(:,2)=reshape(GridY,[],1); 909 par_civ.Grid(:,2)=reshape(GridY,[],1);% increases with array index 909 910 end 910 911 nbvec=size(par_civ.Grid,1); … … 915 916 isx2=ceil(par_civ.SearchBoxSize(1)/2); 916 917 isy2=ceil(par_civ.SearchBoxSize(2)/2); 917 shiftx=round(par_civ.SearchBoxShift(:,1)); 918 shiftx=round(par_civ.SearchBoxShift(:,1));%use the input shift estimate, rounded to the next integer value 918 919 shifty=-round(par_civ.SearchBoxShift(:,2));% sign minus because image j index increases when y decreases 919 920 if numel(shiftx)==1% case of a unique shift for the whole field( civ1) … … 922 923 end 923 924 924 %% Default output925 xtable= par_civ.Grid(:,1);926 ytable= par_civ.Grid(:,2);927 utable= zeros(nbvec,1);928 vtable= zeros(nbvec,1);925 %% Array initialisation and default output if par_civ.CorrSmooth=0 (just the grid calculated, no civ computation) 926 xtable=round(par_civ.Grid(:,1)+0.5)-0.5; 927 ytable=round(par_civ.ImageHeight-par_civ.Grid(:,2)+0.5)-0.5;% y index corresponding to the position in image coordiantes 928 utable=shiftx;%zeros(nbvec,1); 929 vtable=shifty;%zeros(nbvec,1); 929 930 ctable=zeros(nbvec,1); 930 931 F=zeros(nbvec,1); … … 943 944 check_MaxIma=isfield(par_civ,'MaxIma') && ~isempty(par_civ.MaxIma); 944 945 945 % %% prepare images946 % if isfield(par_civ,'reverse_pair')947 % if par_civ.reverse_pair948 % if ischar(par_civ.ImageB)949 % temp=par_civ.ImageA;950 % par_civ.ImageA=imread(par_civ.ImageB);951 % end952 % if ischar(temp)953 % par_civ.ImageB=imread(temp);954 % end955 % end956 % else957 % if ischar(par_civ.ImageA)958 % par_civ.ImageA=imread(par_civ.ImageA);959 % end960 % if ischar(par_civ.ImageB)961 % par_civ.ImageB=imread(par_civ.ImageB);962 % end963 % end964 946 par_civ.ImageA=sum(double(par_civ.ImageA),3);%sum over rgb component for color images 965 947 par_civ.ImageB=sum(double(par_civ.ImageB),3); … … 1000 982 mesh=0.25;%mesh in pixels for subpixel image interpolation (x 4 in each direction) 1001 983 end 1002 if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points viven) 984 985 if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points given) 1003 986 for ivec=1:nbvec 1004 987 iref=round(par_civ.Grid(ivec,1)+0.5);% xindex on the image A for the middle of the correlation box 1005 jref=round(par_civ.ImageHeight-par_civ.Grid(ivec,2)+0.5);% yindex on the image B for the middle of the correlation box988 jref=round(par_civ.ImageHeight-par_civ.Grid(ivec,2)+0.5);% j index for the middle of the correlation box in the image A 1006 989 F(ivec)=0; 1007 990 subrange1_x=iref-ibx2:iref+ibx2;% x indices defining the first subimage … … 1076 1059 else 1077 1060 F(ivec)=3; 1078 [y,x]1079 1061 end 1080 1062 end … … 1085 1067 %------------------------------------------------------------------------ 1086 1068 % --- Find the maximum of the correlation function after interpolation 1069 % OUPUT: 1070 % vector = optimum displacement vector with subpixel correction 1071 % F =flag: =0 OK 1072 % =-2 , warning: max too close to the edge of the search box (1 pixel margin) 1073 % INPUT: 1074 % x,y: position of the maximum correlation at integer values 1075 1087 1076 function [vector,F] = SUBPIXGAUSS (result_conv,x,y) 1088 1077 %------------------------------------------------------------------------ 1089 vector=[0 0]; %default1078 % vector=[0 0]; %default 1090 1079 F=0; 1091 1080 [npy,npx]=size(result_conv); … … 1117 1106 function [vector,F] = SUBPIX2DGAUSS (result_conv,x,y) 1118 1107 %------------------------------------------------------------------------ 1119 vector=[0 0]; %default1108 % vector=[0 0]; %default 1120 1109 F=-2; 1121 1110 peaky=y; -
trunk/src/series/stereo_civ.m
r854 r862 50 50 path_series=fileparts(which('series')); 51 51 addpath(fullfile(path_series,'series')) 52 Data=civ_input(Param);% introduce the civ parameters using the GUI civ_input 52 % Data=civ_input(Param);% introduce the civ parameters using the GUI civ_input 53 Data=stereo_input(Param) 53 54 if isempty(Data) 54 55 Data=Param;% if civ_input has been cancelled, keep previous parameters -
trunk/src/sub_field.m
r811 r862 150 150 151 151 %% append the other variables of the second field, modifying their name if needed 152 for ilist=1:numel(Field_1.ListVarName) 152 ListVarNameNew=Field_1.ListVarName; 153 check_rename=zeros(size(ListVarNameNew)); 154 for ilist=1:numel(ListVarNameNew) 153 155 VarName=Field_1.ListVarName{ilist}; 154 ind_prev=find(strcmp(VarName,Field.ListVarName)); 155 if isempty(ind_prev)% variable name does not exist in Field 156 VarNameNew=VarName; 157 else % variable name exists in Field 158 VarNameNew=[VarName '_1']; 159 if isfield(Field_1.VarAttribute{ilist},'FieldName') 160 Field_1.VarAttribute{ilist}.FieldName=regexprep_r(Field_1.VarAttribute{ilist}.FieldName,VarName,VarNameNew); 161 end 162 end 163 SubData.ListVarName=[SubData.ListVarName {VarNameNew}]; 164 SubData.VarDimName=[SubData.VarDimName Field_1.VarDimName(ilist)]; 165 SubData.(VarNameNew)=Field_1.(VarName); 166 SubData.VarAttribute=[SubData.VarAttribute Field_1.VarAttribute(ilist)]; 167 SubData.VarAttribute{end}.CheckSub=1;% mark that the field needs to be substracted 156 ind_prev=find(strcmp(ListVarNameNew{ilist},Field.ListVarName),1);% look for duplicated variable name 157 if ~isempty(ind_prev)% variable name exists in Field 158 check_rename(ilist)=1; 159 ListVarNameNew{ilist}=[ListVarNameNew{ilist} '_1']; 160 end 161 SubData.ListVarName=[SubData.ListVarName ListVarNameNew{ilist}]; 162 SubData.VarDimName=[SubData.VarDimName Field_1.VarDimName(ilist)]; 163 SubData.(ListVarNameNew{ilist})=Field_1.(VarName);% teke the values of the old variable for the newly named one 164 %SubData.VarAttribute=[SubData.VarAttribute Field_1.VarDimName(ilist)]; 165 end 166 167 %% replace variable name in field expression FieldName, e.g. 'norm(U,V)'-> 'norm(U_1,V_1)' 168 for ilist=1:numel(ListVarNameNew) 169 if check_rename(ilist)&& isfield(Field_1.VarAttribute{ilist},'FieldName') 170 for ivar=1:numel(find(check_rename)) 171 Field_1.VarAttribute{ilist}.FieldName=regexprep_r(Field_1.VarAttribute{ilist}.FieldName,... 172 Field_1.ListVarName{ivar},ListVarNameNew{ivar}); 173 end 174 end 175 SubData.VarAttribute=[SubData.VarAttribute Field_1.VarAttribute(ilist)]; 176 SubData.VarAttribute{end}.CheckSub=1;% mark that the field needs to be substracted as an attribute 168 177 end 169 178 … … 198 207 SubData.VarDimName(find(ind_remove))=[]; 199 208 SubData.VarAttribute(find(ind_remove))=[]; 200 'end'201 209 202 210 function OutputCell=regexprep_r(InputCell,search_string,new_string)
Note: See TracChangeset
for help on using the changeset viewer.