[581] | 1 | %'get_field': display variables and attributes from a Netcdf file, and OK selected fields |
---|
[204] | 2 | %------------------------------------------------------------------------ |
---|
| 3 | %function varargout = get_field(varargin) |
---|
| 4 | % associated with the GUI get_field.fig |
---|
| 5 | % |
---|
| 6 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 7 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
| 8 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 9 | % This file is part of the toolbox UVMAT. |
---|
| 10 | % |
---|
| 11 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 12 | % it under the terms of the GNU General Public License as published by |
---|
| 13 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 14 | % (at your option) any later version. |
---|
| 15 | % |
---|
| 16 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 19 | % GNU General Public License (file UVMAT/COPYING.txt) for more details. |
---|
| 20 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 21 | |
---|
| 22 | function varargout = get_field(varargin) |
---|
| 23 | |
---|
[648] | 24 | % Last Modified by GUIDE v2.5 09-Jun-2013 11:15:54 |
---|
[204] | 25 | |
---|
| 26 | % Begin initialization code - DO NOT EDIT |
---|
[581] | 27 | gui_Singleton = 1; |
---|
[204] | 28 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 29 | 'gui_Singleton', gui_Singleton, ... |
---|
| 30 | 'gui_OpeningFcn', @get_field_OpeningFcn, ... |
---|
| 31 | 'gui_OutputFcn', @get_field_OutputFcn, ... |
---|
| 32 | 'gui_LayoutFcn', [] , ... |
---|
| 33 | 'gui_Callback', []); |
---|
| 34 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 35 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if nargout |
---|
| 39 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
| 40 | else |
---|
| 41 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 42 | end |
---|
| 43 | % End initialization code - DO NOT EDIT |
---|
| 44 | |
---|
| 45 | %------------------------------------------------------------------------ |
---|
| 46 | % --- Executes just before get_field is made visible. |
---|
[648] | 47 | %------------------------------------------------------------------------ |
---|
[581] | 48 | function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn) |
---|
[204] | 49 | |
---|
[648] | 50 | %% GUI settings |
---|
[581] | 51 | handles.output = 'Cancel'; |
---|
[204] | 52 | guidata(hObject, handles); |
---|
[434] | 53 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
[204] | 54 | |
---|
[648] | 55 | %% enter input data |
---|
| 56 | set(handles.inputfile,'String',filename)% fill the input file name |
---|
| 57 | Field=nc2struct(filename,[]);% reads the field structure, without the variables |
---|
| 58 | if isfield(Field,'Txt') |
---|
| 59 | msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input fiel reading |
---|
| 60 | return |
---|
[227] | 61 | end |
---|
[204] | 62 | if ~isfield(Field,'ListVarName') |
---|
| 63 | return |
---|
| 64 | end |
---|
[648] | 65 | if ~exist('ParamIn','var') |
---|
| 66 | ParamIn=[]; |
---|
| 67 | end |
---|
[582] | 68 | |
---|
[648] | 69 | %% look at singletons and variables with a single dimension |
---|
| 70 | Field.Display=Field; |
---|
| 71 | Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value |
---|
| 72 | NbVar=numel(Field.VarDimName); |
---|
| 73 | for ilist=1:NbVar |
---|
[582] | 74 | if ischar(Field.VarDimName{ilist}) |
---|
| 75 | Field.VarDimName{ilist}={Field.VarDimName{ilist}}; %transform string into cell |
---|
| 76 | end |
---|
[648] | 77 | NbDim=numel(Field.VarDimName{ilist}); |
---|
[582] | 78 | check_singleton=false(1,NbDim); |
---|
| 79 | for idim=1:NbDim |
---|
[648] | 80 | dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions |
---|
| 81 | check_singleton(idim)=isequal(Field.DimValue(dim_index),1);%check_singleton=1 for singleton |
---|
[582] | 82 | end |
---|
[648] | 83 | Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim)));% =1 if the variable reduces to a single value |
---|
| 84 | if ~Field.Check0D(ilist) |
---|
| 85 | Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions |
---|
[582] | 86 | end |
---|
[648] | 87 | %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons |
---|
[582] | 88 | end |
---|
[648] | 89 | if numel(Field.VarAttribute)<NbVar% complement VarAttribute by blanjs if neded |
---|
| 90 | Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute)); |
---|
[582] | 91 | end |
---|
[648] | 92 | Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); |
---|
| 93 | Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D); |
---|
| 94 | Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D); |
---|
| 95 | Field.Display.DimValue=Field.DimValue(Field.DimValue~=1); |
---|
| 96 | Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1); |
---|
[581] | 97 | |
---|
[648] | 98 | %% analyse the input field cells |
---|
| 99 | [CellInfo,NbDim,errormsg]=find_field_cells(Field.Display); |
---|
| 100 | if ~isempty(errormsg) |
---|
| 101 | msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg]) |
---|
| 102 | return |
---|
| 103 | end |
---|
| 104 | [Field.MaxDim,imax]=max(NbDim); |
---|
| 105 | |
---|
[581] | 106 | %% set time mode |
---|
[646] | 107 | ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index |
---|
[582] | 108 | % look at global attributes with numerical values |
---|
| 109 | check_numvalue=false; |
---|
| 110 | check_time=false; |
---|
[646] | 111 | for ilist=1:numel(Field.ListGlobalAttribute) |
---|
| 112 | Value=Field.(Field.ListGlobalAttribute{ilist}); |
---|
| 113 | check_numvalue(ilist)=isnumeric(Value); |
---|
| 114 | check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1)); |
---|
| 115 | end |
---|
[648] | 116 | Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value |
---|
| 117 | if ~isempty(Field.Display.ListGlobalAttribute) |
---|
[646] | 118 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute |
---|
[582] | 119 | end |
---|
| 120 | nboption=numel(ListSwitchVarIndexTime); |
---|
| 121 | if Field.MaxDim>=2 |
---|
[646] | 122 | ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index |
---|
[582] | 123 | end |
---|
[648] | 124 | if ~isempty(find(check_time, 1)) |
---|
| 125 | set(handles.SwitchVarIndexTime,'Value',2); |
---|
[581] | 126 | else |
---|
[648] | 127 | set(handles.SwitchVarIndexTime,'Value',1); |
---|
[581] | 128 | end |
---|
[646] | 129 | set(handles.SwitchVarIndexTime,'String',ListSwitchVarIndexTime) |
---|
[582] | 130 | set(handles.get_field,'UserData',Field);% record the finput field structure |
---|
[648] | 131 | SwitchVarIndexTime_Callback([], [], handles) |
---|
[581] | 132 | |
---|
[582] | 133 | %% set vector menu (priority) if detected or scalar menu for space dim >=2, or usual (x,y) plot for 1D fields |
---|
[648] | 134 | set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components |
---|
| 135 | set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components |
---|
| 136 | set(handles.vector_z,'String',[{''} Field.ListVarName])% fill the menu of y vector components |
---|
| 137 | set(handles.vec_color,'String',[{''} Field.ListVarName])% fill the menu of y vector components |
---|
| 138 | set(handles.scalar,'Value',1)% fill the menu of y vector components |
---|
| 139 | set(handles.scalar,'String',Field.ListVarName)% fill the menu of y vector components |
---|
| 140 | set(handles.ordinate,'Value',1)% fill the menu of y vector components |
---|
| 141 | set(handles.ordinate,'String',Field.ListVarName)% fill the menu of y vector components |
---|
[582] | 142 | if Field.MaxDim>=2 % case of 2D (or 3D) fields |
---|
[648] | 143 | if isfield(CellInfo{imax},'VarIndex_vector_x') && isfield(CellInfo{imax},'VarIndex_vector_y') |
---|
[646] | 144 | set(handles.FieldOption,'Value',3)% set vector selection option |
---|
[530] | 145 | set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1)) |
---|
| 146 | set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1)) |
---|
[644] | 147 | set(handles.FieldOption,'Value',3) |
---|
[204] | 148 | else |
---|
[644] | 149 | set(handles.FieldOption,'Value',2) |
---|
[204] | 150 | end |
---|
[582] | 151 | else % case of 1D fields |
---|
[644] | 152 | set(handles.FieldOption,'Value',1) |
---|
[204] | 153 | end |
---|
[582] | 154 | |
---|
[648] | 155 | %% fill the general list of dimensions, variables, attributes |
---|
| 156 | if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) |
---|
| 157 | Tabcell(:,1)=Field.ListDimName; |
---|
| 158 | for iline=1:length(Field.ListDimName) |
---|
| 159 | Tabcell{iline,2}=num2str(Field.DimValue(iline)); |
---|
| 160 | end |
---|
| 161 | Tabchar=cell2tab(Tabcell,' = '); |
---|
| 162 | set(handles.dimensions,'String',Tabchar) |
---|
| 163 | end |
---|
| 164 | set(handles.variables,'Value',1) |
---|
| 165 | set(handles.variables,'String',[{'*'} Field.ListVarName]) |
---|
| 166 | variables_Callback(handles.variables,[], handles)% list the global attributes |
---|
[644] | 167 | |
---|
[648] | 168 | %% fill menus for coordinates and time |
---|
| 169 | FieldOption_Callback(handles.variables,[], handles)% list the global attributes |
---|
| 170 | % if isfield(CellInfo{imax},'VarIndex_coord_x')&& isfield(CellInfo{imax},'VarIndex_coord_y') |
---|
| 171 | % set(handles.Coord_x,'Value',CellInfo{imax}.VarIndex_coord_x(1)) |
---|
| 172 | % set(handles.Coord_y,'Value',CellInfo{imax}.VarIndex_coord_y(1)) |
---|
| 173 | % end |
---|
| 174 | |
---|
[582] | 175 | %% Make choices in menus from input |
---|
[648] | 176 | % if exist('ParamIn','var')&&~isempty(ParamIn) |
---|
| 177 | % fill_GUI(ParamIn,handles.get_field); |
---|
| 178 | % end |
---|
| 179 | %FieldOption_Callback([],[],handles) |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | %% put the GUI on the lower right of the sceen |
---|
| 183 | set(hObject,'Unit','pixel') |
---|
| 184 | pos_view_field=get(hObject,'Position'); |
---|
| 185 | set(0,'Unit','pixels') |
---|
| 186 | ScreenSize=get(0,'ScreenSize'); |
---|
| 187 | pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3); |
---|
| 188 | pos_view_field(2)=ScreenSize(2); |
---|
| 189 | set(hObject,'Position',pos_view_field) |
---|
| 190 | set(handles.get_field,'WindowStyle','modal')% Make the GUI modal |
---|
| 191 | drawnow |
---|
| 192 | uiwait(handles.get_field); |
---|
| 193 | |
---|
| 194 | return |
---|
| 195 | |
---|
| 196 | SwitchVarIndexTime_Callback([],[], handles) |
---|
| 197 | |
---|
| 198 | %% set z coordinate menu if relevant |
---|
| 199 | if Field.MaxDim>=3 |
---|
| 200 | set(handles.vector_z,'Visible','on') |
---|
| 201 | set(handles.vector_z,'String',Field.ListVarName(~Field.Check0D)) |
---|
| 202 | set(handles.Coord_z,'Visible','on') |
---|
| 203 | set(handles.SwitchVarIndexZ,'Visible','on') |
---|
| 204 | set(handles.Z_title,'Visible','on') |
---|
| 205 | else |
---|
| 206 | set(handles.vector_z,'Visible','off') |
---|
| 207 | set(handles.Coord_z,'Visible','off') |
---|
| 208 | set(handles.Z_title,'Visible','off') |
---|
[581] | 209 | end |
---|
[204] | 210 | |
---|
[648] | 211 | |
---|
| 212 | |
---|
[204] | 213 | %------------------------------------------------------------------------ |
---|
[648] | 214 | |
---|
| 215 | %------------------------------------------------------------------------ |
---|
[582] | 216 | % --- Outputs from this function are returned to the command line. |
---|
| 217 | function varargout = get_field_OutputFcn(hObject, eventdata, handles) |
---|
| 218 | %------------------------------------------------------------------------ |
---|
| 219 | varargout{1} = handles.output; |
---|
| 220 | delete(handles.get_field) |
---|
| 221 | |
---|
[648] | 222 | %------------------------------------------------------------------------ |
---|
| 223 | % --- Executes when user attempts to close get_field. |
---|
| 224 | %------------------------------------------------------------------------ |
---|
| 225 | function get_field_CloseRequestFcn(hObject, eventdata, handles) |
---|
[582] | 226 | |
---|
[648] | 227 | if isequal(get(handles.get_field, 'waitstatus'), 'waiting') |
---|
| 228 | % The GUI is still in UIWAIT, us UIRESUME |
---|
| 229 | uiresume(handles.get_field); |
---|
| 230 | else |
---|
| 231 | % The GUI is no longer waiting, just close it |
---|
| 232 | delete(handles.get_field); |
---|
| 233 | end |
---|
| 234 | |
---|
| 235 | %--------------------------------------------------------- |
---|
| 236 | % --- Executes on button press in OK. |
---|
| 237 | %------------------------------------------------------------------------ |
---|
| 238 | function OK_Callback(hObject, eventdata, handles) |
---|
| 239 | |
---|
| 240 | handles.output=read_GUI(handles.get_field); |
---|
| 241 | guidata(hObject, handles);% Update handles structure |
---|
| 242 | uiresume(handles.get_field); |
---|
| 243 | drawnow |
---|
| 244 | |
---|
[582] | 245 | % ----------------------------------------------------------------------- |
---|
| 246 | % --- Activated by selection in the list of variables |
---|
| 247 | function variables_Callback(hObject, eventdata, handles) |
---|
| 248 | % ----------------------------------------------------------------------- |
---|
| 249 | Tabchar={''};%default |
---|
| 250 | Tabcell=[]; |
---|
| 251 | hselect_field=get(handles.variables,'parent'); |
---|
| 252 | Field=get(handles.get_field,'UserData'); |
---|
| 253 | index=get(handles.variables,'Value');%index in the list 'variables' |
---|
| 254 | |
---|
| 255 | %% list global TimeAttribute names and values if index=1 (blank TimeVariable display) is selected |
---|
| 256 | if isequal(index,1) |
---|
| 257 | set(handles.attributes_txt,'String','global attributes') |
---|
| 258 | if isfield(Field,'ListGlobalAttribute') && ~isempty(Field.ListGlobalAttribute) |
---|
| 259 | for iline=1:length(Field.ListGlobalAttribute) |
---|
| 260 | Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; |
---|
| 261 | if isfield(Field, Field.ListGlobalAttribute{iline}) |
---|
[648] | 262 | val=Field.(Field.ListGlobalAttribute{iline}); |
---|
[582] | 263 | if ischar(val);% attribute value is char string |
---|
| 264 | Tabcell{iline,2}=val; |
---|
| 265 | elseif size(val,1)==1 %attribute value is a number or matlab vector |
---|
| 266 | Tabcell{iline,2}=num2str(val); |
---|
| 267 | end |
---|
| 268 | end |
---|
| 269 | end |
---|
| 270 | Tabchar=cell2tab(Tabcell,'='); |
---|
| 271 | end |
---|
| 272 | %% list Attribute names and values associated to the Variable # index-1 |
---|
| 273 | else |
---|
| 274 | list_var=get(handles.variables,'String'); |
---|
| 275 | var_select=list_var{index}; |
---|
| 276 | set(handles.attributes_txt,'String', ['attributes of ' var_select]) |
---|
| 277 | if isfield(Field,'VarAttribute')&& length(Field.VarAttribute)>=index-1 |
---|
| 278 | % nbline=0; |
---|
| 279 | VarAttr=Field.VarAttribute{index-1}; |
---|
| 280 | if isstruct(VarAttr) |
---|
| 281 | attr_list=fieldnames(VarAttr); |
---|
| 282 | for iline=1:length(attr_list) |
---|
| 283 | Tabcell{iline,1}=attr_list{iline}; |
---|
| 284 | eval(['val=VarAttr.' attr_list{iline} ';']) |
---|
| 285 | if ischar(val); |
---|
| 286 | Tabcell{iline,2}=val; |
---|
| 287 | else |
---|
| 288 | Tabcell{iline,2}=num2str(val); |
---|
| 289 | end |
---|
| 290 | end |
---|
| 291 | end |
---|
| 292 | end |
---|
| 293 | |
---|
| 294 | end |
---|
| 295 | if ~isempty(Tabcell) |
---|
| 296 | Tabchar=cell2tab(Tabcell,'='); |
---|
[648] | 297 | % Tabchar=[{''};Tabchar]; |
---|
[582] | 298 | end |
---|
| 299 | set(handles.attributes,'Value',1);% select the first item |
---|
| 300 | set(handles.attributes,'String',Tabchar); |
---|
| 301 | |
---|
| 302 | %% update dimensions; |
---|
| 303 | if isfield(Field,'ListDimName') |
---|
| 304 | Tabdim={};%default |
---|
| 305 | if isequal(index,1)%list all dimensions |
---|
| 306 | dim_indices=1:length(Field.ListDimName); |
---|
| 307 | set(handles.dimensions_txt,'String', 'dimensions') |
---|
| 308 | else |
---|
| 309 | DimCell=Field.VarDimName{index-1}; |
---|
| 310 | if ischar(DimCell) |
---|
| 311 | DimCell={DimCell}; |
---|
| 312 | end |
---|
| 313 | dim_indices=[]; |
---|
| 314 | for idim=1:length(DimCell) |
---|
| 315 | dim_index=strcmp(DimCell{idim},Field.ListDimName);%vector with size of Field.ListDimName, =0 |
---|
| 316 | dim_index=find(dim_index,1); |
---|
| 317 | dim_indices=[dim_indices dim_index]; |
---|
| 318 | end |
---|
| 319 | set(handles.dimensions_txt,'String', ['dimensions of ' var_select]) |
---|
| 320 | end |
---|
| 321 | for iline=1:length(dim_indices) |
---|
| 322 | Tabdim{iline,1}=Field.ListDimName{dim_indices(iline)}; |
---|
| 323 | Tabdim{iline,2}=num2str(Field.DimValue(dim_indices(iline))); |
---|
| 324 | end |
---|
| 325 | Tabchar=cell2tab(Tabdim,' = '); |
---|
| 326 | Tabchar=[{''} ;Tabchar]; |
---|
| 327 | set(handles.dimensions,'Value',1) |
---|
| 328 | set(handles.dimensions,'String',Tabchar) |
---|
| 329 | end |
---|
| 330 | |
---|
| 331 | %------------------------------------------------------------------------ |
---|
[648] | 332 | % --- Executes on selection change in FieldOption. |
---|
[582] | 333 | %------------------------------------------------------------------------ |
---|
[648] | 334 | function FieldOption_Callback(hObject, eventdata, handles) |
---|
| 335 | |
---|
| 336 | FieldList=get(handles.FieldOption,'String'); |
---|
| 337 | FieldOption=FieldList{get(handles.FieldOption,'Value')}; |
---|
| 338 | switch FieldOption |
---|
| 339 | case '1D plot' |
---|
| 340 | set(handles.PanelOrdinate,'Visible','on') |
---|
| 341 | pos=get(handles.PanelOrdinate,'Position'); |
---|
| 342 | pos(1)=2; |
---|
| 343 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 344 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 345 | set(handles.PanelOrdinate,'Position',pos) |
---|
| 346 | set(handles.PanelScalar,'Visible','off') |
---|
| 347 | set(handles.PanelVectors,'Visible','off') |
---|
| 348 | set(handles.Coord_y,'Visible','off') |
---|
| 349 | set(handles.Y_title,'Visible','off') |
---|
| 350 | set(handles.Coord_z,'Visible','off') |
---|
| 351 | set(handles.Z_title,'Visible','off') |
---|
| 352 | ordinate_Callback(hObject, eventdata, handles) |
---|
| 353 | case 'scalar' |
---|
| 354 | set(handles.PanelOrdinate,'Visible','off') |
---|
| 355 | set(handles.PanelScalar,'Visible','on') |
---|
| 356 | set(handles.PanelVectors,'Visible','off') |
---|
| 357 | pos=get(handles.PanelScalar,'Position'); |
---|
| 358 | pos(1)=2; |
---|
| 359 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 360 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 361 | set(handles.PanelScalar,'Position',pos) |
---|
| 362 | set(handles.Coord_y,'Visible','on') |
---|
| 363 | set(handles.Y_title,'Visible','on') |
---|
| 364 | scalar_Callback(hObject, eventdata, handles) |
---|
| 365 | case 'vectors' |
---|
| 366 | set(handles.PanelOrdinate,'Visible','off') |
---|
| 367 | set(handles.PanelScalar,'Visible','off') |
---|
| 368 | set(handles.PanelVectors,'Visible','on') |
---|
| 369 | pos=get(handles.PanelVectors,'Position'); |
---|
| 370 | pos(1)=2; |
---|
| 371 | pos_coord=get(handles.Coordinates,'Position'); |
---|
| 372 | pos(2)=pos_coord(2)-pos(4)-2; |
---|
| 373 | set(handles.PanelVectors,'Position',pos) |
---|
| 374 | set(handles.Coord_y,'Visible','on') |
---|
| 375 | set(handles.Y_title,'Visible','on') |
---|
| 376 | vector_Callback(handles) |
---|
[582] | 377 | end |
---|
| 378 | |
---|
| 379 | %------------------------------------------------------------------------ |
---|
[204] | 380 | function ordinate_Callback(hObject, eventdata, handles) |
---|
| 381 | %------------------------------------------------------------------------ |
---|
[582] | 382 | Field=get(handles.get_field,'UserData'); |
---|
[648] | 383 | y_index=get(handles.ordinate,'Value'); |
---|
| 384 | y_menu=get(handles.ordinate,'String'); |
---|
| 385 | YName=y_menu{y_index}; |
---|
| 386 | |
---|
| 387 | %% set list of possible coordinates |
---|
| 388 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
| 389 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 390 | ListCoord={''}; |
---|
| 391 | dim_var=Field.Display.VarDimName{y_index};%list of dimensions of the selected variable |
---|
| 392 | |
---|
| 393 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 394 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 395 | if isequal(dimnames,dim_var) |
---|
| 396 | test_component(ilist)=1; |
---|
| 397 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
---|
| 398 | test_coord(ilist)=1; |
---|
[582] | 399 | end |
---|
| 400 | end |
---|
[648] | 401 | var_component=find(test_component);% list of variable indices elligible as unstructured coordinates |
---|
| 402 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
| 403 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
---|
[204] | 404 | |
---|
[648] | 405 | %% set default coord selection |
---|
| 406 | if numel(find(test_coord))>3 |
---|
| 407 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
[582] | 408 | end |
---|
[648] | 409 | if numel(var_component)<2 |
---|
| 410 | if numel(test_coord)<2 |
---|
| 411 | ListCoord={''}; |
---|
| 412 | else |
---|
| 413 | set(handles.Coord_x,'Value',2) |
---|
| 414 | set(handles.Coord_y,'Value',1) |
---|
| 415 | end |
---|
[582] | 416 | else |
---|
[648] | 417 | coord_val=1; |
---|
| 418 | for ilist=1:numel(var_component) |
---|
| 419 | ivar=var_component(ilist); |
---|
| 420 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
---|
| 421 | Role=Field.Display.VarAttribute{ivar}.Role; |
---|
| 422 | if strcmp(Role,'coord_x') |
---|
| 423 | coord_val=ilist; |
---|
| 424 | end |
---|
| 425 | end |
---|
| 426 | end |
---|
| 427 | set(handles.Coord_x,'Value',coord_val) |
---|
[582] | 428 | end |
---|
[648] | 429 | set(handles.Coord_x,'String',ListCoord) |
---|
[582] | 430 | |
---|
| 431 | |
---|
[648] | 432 | %% set list of time coordinates |
---|
| 433 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 434 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
| 435 | switch TimeOption |
---|
| 436 | case 'variable' |
---|
| 437 | if numel(find(test_coord))<3 |
---|
| 438 | ListTime={''}; |
---|
| 439 | else |
---|
| 440 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
---|
| 441 | end |
---|
| 442 | set(handles.TimeName,'Value',1) |
---|
| 443 | set(handles.TimeName,'String',ListTime) |
---|
| 444 | case 'dim index' |
---|
| 445 | if numel(find(test_coord))<3 |
---|
| 446 | ListTime={''}; |
---|
| 447 | else |
---|
| 448 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
---|
| 449 | end |
---|
| 450 | set(handles.TimeName,'Value',1) |
---|
| 451 | set(handles.TimeName,'String',ListTime) |
---|
| 452 | end |
---|
| 453 | update_field(handles,YName) |
---|
| 454 | |
---|
[582] | 455 | %------------------------------------------------------------------------ |
---|
[204] | 456 | % --- Executes on selection change in scalar menu. |
---|
[648] | 457 | %------------------------------------------------------------------------ |
---|
[204] | 458 | function scalar_Callback(hObject, eventdata, handles) |
---|
[648] | 459 | |
---|
[586] | 460 | Field=get(handles.get_field,'UserData'); |
---|
[648] | 461 | scalar_index=get(handles.scalar,'Value'); |
---|
| 462 | scalar_menu=get(handles.scalar,'String'); |
---|
| 463 | ScalarName=scalar_menu{scalar_index}; |
---|
[204] | 464 | |
---|
[648] | 465 | %% set list of possible coordinates |
---|
| 466 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
| 467 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 468 | ListCoord={''}; |
---|
| 469 | dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable |
---|
[646] | 470 | |
---|
[648] | 471 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 472 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 473 | if isequal(dimnames,dim_var) |
---|
| 474 | test_component(ilist)=1; |
---|
| 475 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
---|
| 476 | test_coord(ilist)=1; |
---|
| 477 | end |
---|
[227] | 478 | end |
---|
[648] | 479 | var_component=find(test_component);% list of variable indices elligible as unstructured coordiantes |
---|
| 480 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
| 481 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
---|
[227] | 482 | |
---|
[648] | 483 | %% set default coord selection |
---|
| 484 | if numel(find(test_coord))>3 |
---|
| 485 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
| 486 | end |
---|
| 487 | if numel(var_component)<2 |
---|
| 488 | if numel(test_coord)<2 |
---|
| 489 | ListCoord={''}; |
---|
| 490 | else |
---|
| 491 | set(handles.Coord_x,'Value',2) |
---|
| 492 | set(handles.Coord_y,'Value',1) |
---|
[227] | 493 | end |
---|
[648] | 494 | else |
---|
| 495 | coord_val=[1 2]; |
---|
| 496 | for ilist=1:numel(var_component) |
---|
| 497 | ivar=var_component(ilist); |
---|
| 498 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
---|
| 499 | Role=Field.Display.VarAttribute{ivar}.Role; |
---|
| 500 | if strcmp(Role,'coord_x') |
---|
| 501 | coord_val(1)=ilist; |
---|
| 502 | elseif strcmp(Role,'coord_y') |
---|
| 503 | coord_val(2)=ilist; |
---|
| 504 | end |
---|
[227] | 505 | end |
---|
| 506 | end |
---|
[648] | 507 | set(handles.Coord_x,'Value',coord_val(1)) |
---|
| 508 | set(handles.Coord_y,'Value',coord_val(2)) |
---|
[227] | 509 | end |
---|
| 510 | |
---|
[648] | 511 | set(handles.Coord_y,'String',ListCoord) |
---|
| 512 | set(handles.Coord_x,'String',ListCoord) |
---|
[227] | 513 | |
---|
| 514 | |
---|
[648] | 515 | %% set list of time coordinates |
---|
| 516 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 517 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
| 518 | switch TimeOption |
---|
| 519 | case 'variable' |
---|
| 520 | if numel(find(test_coord))<3 |
---|
| 521 | ListTime={''}; |
---|
| 522 | else |
---|
| 523 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
---|
| 524 | end |
---|
| 525 | set(handles.TimeName,'Value',1) |
---|
| 526 | set(handles.TimeName,'String',ListTime) |
---|
| 527 | case 'dim index' |
---|
| 528 | if numel(find(test_coord))<3 |
---|
| 529 | ListTime={''}; |
---|
| 530 | else |
---|
| 531 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
---|
| 532 | end |
---|
| 533 | set(handles.TimeName,'Value',1) |
---|
| 534 | set(handles.TimeName,'String',ListTime) |
---|
| 535 | end |
---|
| 536 | update_field(handles,ScalarName) |
---|
[582] | 537 | |
---|
[648] | 538 | % --- Executes on button press in check_rgb. |
---|
| 539 | function check_rgb_Callback(hObject, eventdata, handles) |
---|
[582] | 540 | |
---|
| 541 | |
---|
| 542 | %------------------------------------------------------------------------ |
---|
[204] | 543 | % --- Executes on selection change in vector_x. |
---|
| 544 | function vector_x_Callback(hObject, eventdata, handles) |
---|
| 545 | %------------------------------------------------------------------------ |
---|
[648] | 546 | vector_x_menu=get(handles.vector_x,'String'); |
---|
| 547 | vector_x_index=get(handles.vector_x,'Value'); |
---|
| 548 | vector_x=vector_x_menu{vector_x_index}; |
---|
| 549 | vector_Callback(handles) |
---|
| 550 | update_field(handles,vector_x) |
---|
[227] | 551 | |
---|
[204] | 552 | %------------------------------------------------------------------------ |
---|
[648] | 553 | % --- Executes on selection change in vector_x. |
---|
[204] | 554 | function vector_y_Callback(hObject, eventdata, handles) |
---|
| 555 | %------------------------------------------------------------------------ |
---|
[648] | 556 | vector_y_menu=get(handles.vector_x,'String'); |
---|
| 557 | vector_y_index=get(handles.vector_x,'Value'); |
---|
| 558 | vector_y=vector_y_menu{vector_y_index}; |
---|
| 559 | vector_Callback(handles) |
---|
| 560 | update_field(handles,vector_y) |
---|
[204] | 561 | |
---|
| 562 | %------------------------------------------------------------------------ |
---|
| 563 | % --- Executes on selection change in vector_z. |
---|
| 564 | function vector_z_Callback(hObject, eventdata, handles) |
---|
| 565 | %------------------------------------------------------------------------ |
---|
[648] | 566 | vector_z_menu=get(handles.vector_z,'String'); |
---|
| 567 | vector_z_index=get(handles.vector_z,'Value'); |
---|
| 568 | vector_z=vector_z_menu{vector_z_index}; |
---|
| 569 | vector_Callback(handles) |
---|
| 570 | update_field(handles,vector_z) |
---|
[204] | 571 | |
---|
| 572 | %------------------------------------------------------------------------ |
---|
| 573 | % --- Executes on selection change in vec_color. |
---|
| 574 | function vec_color_Callback(hObject, eventdata, handles) |
---|
[227] | 575 | %------------------------------------------------------------------------ |
---|
[204] | 576 | index=get(handles.vec_color,'Value'); |
---|
| 577 | string=get(handles.vec_color,'String'); |
---|
| 578 | VarName=string{index}; |
---|
[648] | 579 | vector_Callback(handles) |
---|
| 580 | update_field(handles,VarName) |
---|
[204] | 581 | |
---|
[227] | 582 | %------------------------------------------------------------------------ |
---|
[648] | 583 | % --- Executes on selection change in vector_x or vector_y |
---|
| 584 | function vector_Callback( handles) |
---|
[227] | 585 | %------------------------------------------------------------------------ |
---|
[648] | 586 | Field=get(handles.get_field,'UserData'); |
---|
| 587 | vector_x_index=get(handles.vector_x,'Value'); |
---|
| 588 | vector_y_index=get(handles.vector_y,'Value'); |
---|
| 589 | vec_color_index=get(handles.vec_color,'Value'); |
---|
[204] | 590 | |
---|
[648] | 591 | %% set list of possible coordinates |
---|
| 592 | test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate |
---|
| 593 | test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante |
---|
| 594 | check_consistent=1;%check that the selected vector components (and possibly color var) have the same dimensiosn |
---|
| 595 | ListCoord={''}; |
---|
| 596 | dim_var=Field.Display.VarDimName{vector_x_index};%list of dimensions of the selected variable |
---|
| 597 | if ~isequal(dim_var,Field.Display.VarDimName{vector_y_index}) |
---|
| 598 | check_consistent=0; |
---|
| 599 | elseif vec_color_index~=1 && ~isequal(dim_var,Field.Display.VarDimName{vec_color_index}) |
---|
| 600 | check_consistent=0; |
---|
[204] | 601 | end |
---|
[648] | 602 | if check_consistent |
---|
| 603 | for ilist=1:numel(Field.Display.VarDimName) |
---|
| 604 | dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist |
---|
| 605 | if isequal(dimnames,dim_var) |
---|
| 606 | test_component(ilist)=1; |
---|
| 607 | elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable |
---|
| 608 | test_coord(ilist)=1; |
---|
[204] | 609 | end |
---|
| 610 | end |
---|
[648] | 611 | var_component=find(test_component);% list of variable indices elligible as unstructured coordiantes |
---|
| 612 | var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates |
---|
| 613 | ListCoord=Field.Display.ListVarName([var_component var_coord]); |
---|
| 614 | |
---|
| 615 | %% set default coord selection |
---|
| 616 | if numel(find(test_coord))>3 |
---|
| 617 | set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time |
---|
[204] | 618 | end |
---|
[648] | 619 | if numel(var_component)<2 |
---|
| 620 | if numel(test_coord)<2 |
---|
| 621 | ListCoord={''}; |
---|
| 622 | else |
---|
| 623 | set(handles.Coord_x,'Value',2) |
---|
| 624 | set(handles.Coord_y,'Value',1) |
---|
[204] | 625 | end |
---|
| 626 | else |
---|
[648] | 627 | coord_val=[1 2]; |
---|
| 628 | for ilist=1:numel(var_component) |
---|
| 629 | ivar=var_component(ilist); |
---|
| 630 | if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ivar && isfield(Field.Display.VarAttribute{ivar},'Role') |
---|
| 631 | Role=Field.Display.VarAttribute{ivar}.Role; |
---|
| 632 | if strcmp(Role,'coord_x') |
---|
| 633 | coord_val(1)=ilist; |
---|
| 634 | elseif strcmp(Role,'coord_y') |
---|
| 635 | coord_val(2)=ilist; |
---|
| 636 | end |
---|
[526] | 637 | end |
---|
| 638 | end |
---|
[648] | 639 | set(handles.Coord_x,'Value',coord_val(1)) |
---|
| 640 | set(handles.Coord_y,'Value',coord_val(2)) |
---|
[526] | 641 | end |
---|
[204] | 642 | end |
---|
[648] | 643 | set(handles.Coord_y,'String',ListCoord) |
---|
| 644 | set(handles.Coord_x,'String',ListCoord) |
---|
[204] | 645 | |
---|
| 646 | |
---|
[648] | 647 | %% set list of time coordinates |
---|
| 648 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 649 | TimeOption=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
| 650 | switch TimeOption |
---|
| 651 | case 'variable' |
---|
| 652 | if numel(find(test_coord))<3 |
---|
| 653 | ListTime={''}; |
---|
| 654 | else |
---|
| 655 | ListTime=Field.Display.ListVarName(find(test_coord,end)); |
---|
[204] | 656 | end |
---|
[648] | 657 | set(handles.TimeName,'Value',1) |
---|
| 658 | set(handles.TimeName,'String',ListTime) |
---|
| 659 | case 'dim index' |
---|
| 660 | if numel(find(test_coord))<3 |
---|
| 661 | ListTime={''}; |
---|
| 662 | else |
---|
| 663 | ListTime=Field.Display.VarDimName{find(test_coord,end)}; |
---|
[204] | 664 | end |
---|
[648] | 665 | set(handles.TimeName,'Value',1) |
---|
| 666 | set(handles.TimeName,'String',ListTime) |
---|
| 667 | end |
---|
[204] | 668 | |
---|
[227] | 669 | %------------------------------------------------------------------------ |
---|
[648] | 670 | % --- Executes on selection change in SwitchVarIndexX. |
---|
[227] | 671 | %------------------------------------------------------------------------ |
---|
[648] | 672 | function SwitchVarIndexX_Callback(hObject, eventdata, handles) |
---|
[227] | 673 | |
---|
| 674 | %------------------------------------------------------------------------ |
---|
[648] | 675 | % --- Executes on selection change in Coord_x. |
---|
| 676 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
[227] | 677 | %------------------------------------------------------------------------ |
---|
[648] | 678 | index=get(handles.Coord_x,'Value'); |
---|
| 679 | string=get(handles.Coord_x,'String'); |
---|
| 680 | VarName=string{index}; |
---|
| 681 | update_field(handles,VarName) |
---|
[227] | 682 | |
---|
| 683 | %------------------------------------------------------------------------ |
---|
[648] | 684 | % --- Executes on selection change in Coord_y. |
---|
| 685 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
[227] | 686 | %------------------------------------------------------------------------ |
---|
[648] | 687 | index=get(handles.Coord_y,'Value'); |
---|
| 688 | string=get(handles.Coord_y,'String'); |
---|
| 689 | VarName=string{index}; |
---|
| 690 | update_field(handles,VarName) |
---|
[227] | 691 | |
---|
[646] | 692 | %------------------------------------------------------------------------ |
---|
[648] | 693 | % --- Executes on selection change in Coord_z. |
---|
| 694 | function Coord_z_Callback(hObject, eventdata, handles) |
---|
[646] | 695 | %------------------------------------------------------------------------ |
---|
[648] | 696 | index=get(handles.Coord_z,'Value'); |
---|
| 697 | string=get(handles.Coord_z,'String'); |
---|
| 698 | VarName=string{index}; |
---|
| 699 | update_field(handles,VarName) |
---|
[581] | 700 | |
---|
[646] | 701 | %------------------------------------------------------------------------ |
---|
[581] | 702 | % --- Executes on selection change in SwitchVarIndexTime. |
---|
[646] | 703 | %------------------------------------------------------------------------ |
---|
[581] | 704 | function SwitchVarIndexTime_Callback(hObject, eventdata, handles) |
---|
[648] | 705 | Field=get(handles.get_field,'UserData'); |
---|
[581] | 706 | menu=get(handles.SwitchVarIndexTime,'String'); |
---|
| 707 | option=menu{get(handles.SwitchVarIndexTime,'Value')}; |
---|
[648] | 708 | |
---|
[581] | 709 | switch option |
---|
| 710 | case 'file index' |
---|
[648] | 711 | set(handles.TimeName, 'Visible','off')% the time is taken as the file index |
---|
[581] | 712 | case 'attribute' |
---|
[648] | 713 | set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes |
---|
[581] | 714 | time_index=[]; |
---|
[648] | 715 | PreviousList=get(handles.TimeName, 'String'); |
---|
| 716 | index=[]; |
---|
[582] | 717 | if ~isempty(PreviousList) |
---|
[648] | 718 | PreviousAttr=PreviousList{get(handles.TimeName, 'Value')}; |
---|
| 719 | index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes)); |
---|
[581] | 720 | end |
---|
[582] | 721 | if isempty(index) |
---|
[648] | 722 | time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time' |
---|
[582] | 723 | end |
---|
[581] | 724 | if ~isempty(time_index) |
---|
[648] | 725 | set(handles.TimeName,'Value',time_index(1)) |
---|
[581] | 726 | else |
---|
[648] | 727 | set(handles.TimeName,'Value',1) |
---|
[581] | 728 | end |
---|
[648] | 729 | set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute) |
---|
| 730 | case 'variable'% TimeName menu represents the available variables |
---|
| 731 | set(handles.TimeName, 'Visible','on') |
---|
| 732 | TimeVarName=Field.Display.SingleVarName;% slist of variables with a single dimension (candidate for time) |
---|
| 733 | List=get(handles.TimeName,'String'); |
---|
| 734 | option=List{get(handles.TimeName,'Value')}; |
---|
[582] | 735 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 736 | if isempty(ind) |
---|
[648] | 737 | set(handles.TimeName, 'Value',1); |
---|
[581] | 738 | else |
---|
[648] | 739 | set(handles.TimeName, 'Value',ind); |
---|
[581] | 740 | end |
---|
[648] | 741 | set(handles.TimeName, 'String',TimeVarName) |
---|
| 742 | case 'dim index'% TimeName menu represents the available dimensions |
---|
| 743 | set(handles.TimeName, 'Visible','on') |
---|
| 744 | TimeVarName=Field.Display.SingleDimName; |
---|
| 745 | List=get(handles.TimeName,'String'); |
---|
| 746 | option=List{get(handles.TimeName,'Value')}; |
---|
[582] | 747 | ind=find(strcmp(option,TimeVarName)); |
---|
[581] | 748 | if isempty(ind) |
---|
[648] | 749 | set(handles.TimeName, 'Value',1); |
---|
[581] | 750 | else |
---|
[648] | 751 | set(handles.TimeName, 'Value',ind); |
---|
[581] | 752 | end |
---|
[648] | 753 | set(handles.TimeName, 'String',TimeVarName) |
---|
[581] | 754 | end |
---|
| 755 | |
---|
[648] | 756 | %----------------------------------------------------------------------- |
---|
| 757 | function update_field(handles,VarName) |
---|
| 758 | %----------------------------------------------------------------------- |
---|
| 759 | Field=get(handles.get_field,'UserData'); |
---|
| 760 | index=name2index(VarName,Field.ListVarName); |
---|
| 761 | if ~isempty(index) |
---|
| 762 | set(handles.variables,'Value',index+1) |
---|
| 763 | variables_Callback(handles.variables, [], handles) |
---|
[644] | 764 | end |
---|
[648] | 765 | |
---|
| 766 | %------------------------------------------------- |
---|
| 767 | % give index numbers of the strings str in the list ListvarName |
---|
| 768 | function VarIndex_y=name2index(cell_str,ListVarName) |
---|
| 769 | VarIndex_y=[]; |
---|
| 770 | if ischar(cell_str) |
---|
| 771 | for ivar=1:length(ListVarName) |
---|
| 772 | varlist=ListVarName{ivar}; |
---|
| 773 | if isequal(varlist,cell_str) |
---|
| 774 | VarIndex_y= ivar; |
---|
| 775 | break |
---|
| 776 | end |
---|
| 777 | end |
---|
| 778 | elseif iscell(cell_str) |
---|
| 779 | for isel=1:length(cell_str) |
---|
| 780 | varsel=cell_str{isel}; |
---|
| 781 | for ivar=1:length(ListVarName) |
---|
| 782 | varlist=ListVarName{ivar}; |
---|
| 783 | if isequal(varlist,varsel) |
---|
| 784 | VarIndex_y=[VarIndex_y ivar]; |
---|
| 785 | end |
---|
| 786 | end |
---|
| 787 | end |
---|
| 788 | end |
---|