0001 function plot_tensor_principalaxis(md,options_structure,width,i,tensor,type,plot_options);
0002
0003
0004
0005
0006
0007
0008
0009
0010 subplot(width,width,i);
0011
0012
0013 if (strcmpi(md.type,'2d')),
0014 eval(['Vx=tensor.principalaxis' type(end) '(:,1); Vy=tensor.principalaxis' type(end) '(:,2);'])
0015 else
0016 eval(['Vx=tensor.principalaxis' type(end) '(:,1); Vy=tensor.principalaxis' type(end) '(:,2); Vz=tensor.principalaxis' type(end) '(:,3);'])
0017 end
0018
0019
0020 if strcmpi(options_structure.smooth,'yes') & length(Vx)==md.numberofelements
0021 Vx=elementstogrids(md,Vx);
0022 Vy=elementstogrids(md,Vy);
0023 if (strcmpi(md.type,'3d')),
0024 Vz=elementstogrids(md,Vz);
0025 end
0026 end
0027
0028
0029 if ~isnan(options_structure.layer) & options_structure.layer>=1,
0030 Vx=project2d(md,Vx,options_structure.layer);
0031 Vy=project2d(md,Vy,options_structure.layer);
0032 if (strcmpi(md.type,'3d')),
0033 Vz=project2d(md,Vz,options_structure.layer);
0034 end
0035
0036 md.x=md.x2d;
0037 md.y=md.y2d;
0038 md.z=md.z2d;
0039 md.elements=md.elements2d;
0040 md.elements_type=md.elements_type2d;
0041 md.type='2d';
0042 end
0043
0044
0045 if ~isnan(options_structure.unitmultiplier),
0046 md.x=md.x*options_structure.unitmultiplier;
0047 md.y=md.y*options_structure.unitmultiplier;
0048 md.z=md.z*options_structure.unitmultiplier;
0049 end
0050 if length(Vx)==length(md.elements),
0051
0052 if ~isnan(options_structure.noiceshelf) & options_structure.noiceshelf,
0053 Vx(find(md.elementoniceshelf))=NaN;
0054 Vy(find(md.elementoniceshelf))=NaN;
0055 Vz(find(md.elementoniceshelf))=NaN;
0056 end
0057 if ~isnan(options_structure.noicesheet) & options_structure.noicesheet,
0058 Vx(find(~md.elementoniceshelf))=NaN;
0059 Vy(find(~md.elementoniceshelf))=NaN;
0060 Vz(find(~md.elementoniceshelf))=NaN;
0061 end
0062
0063 if (strcmpi(md.type,'2d')),
0064 x=mean(md.x(md.elements'))'; y=mean(md.y(md.elements'))';
0065 A=md.elements(:,1); B=md.elements(:,2); C=md.elements(:,3);
0066 quiver(x,y,Vx,Vy)
0067
0068 else
0069 x=mean(md.x(md.elements'))'; y=mean(md.y(md.elements'))'; z=mean(md.z(md.elements'))';
0070 A=md.elements(:,1); B=md.elements(:,2); C=md.elements(:,3); D=md.elements(:,4); E=md.elements(:,5); F=md.elements(:,6);
0071 quiver3(x,y,z,Vx,Vy,Vz)
0072 end
0073 elseif length(Vx)==md.numberofgrids | length(Vx)==md.numberofgrids2d,
0074 if ~isnan(options_structure.noiceshelf) & options_structure.noiceshelf,
0075 pos=find(md.gridoniceshelf);
0076 Vx(pos)=NaN;
0077 Vy(pos)=NaN;
0078 Vz(pos)=NaN;
0079 end
0080 if ~isnan(options_structure.noiceshelf) & options_structure.noicesheet,
0081 pos=find(md.gridonicesheet);
0082 Vx(pos)=NaN;
0083 Vy(pos)=NaN;
0084 Vz(pos)=NaN;
0085 end
0086
0087 if strcmpi(md.type,'2d'),
0088 quiver(md.x,md.y,Vx,Vy)
0089 else
0090 quiver3(md.x,md.y,md.z,Vx,Vy,Vz)
0091 end
0092 end
0093
0094
0095 if isnan(options_structure.title)
0096 strings=strsplit(type,'_');
0097 string=strings{1};
0098 options_structure.title=[upper(string(1)) string(2:end) ' principal axis ' type(end)];
0099 end
0100 if isnan(options_structure.colorbar)
0101 options_structure.colorbar=0;
0102 end
0103 applyoptions(md,[],options_structure);