?? showlatt.m
字號:
function showlatt(latt,varargin)%SHOWLATT Display designed lattice% SHOWLATT(L) displays N-dimensional lattice; N = {1,2,3} and assigns% unique number to each element. %% SHOWLATT(L,'PropertyName',PropertyValue,...)%% Showlatt Property List%% Style value% Labeling {'none'} | 'num' | custom% Echo 'on' | {'off'}%% Example:% Z2 = makelatt('Z',9,2)% RZ2 = rotlatt(Z2)% showlatt(RZ2,'Style',1); hold on;% showlatt(Z2,'Labeling','num');%% See also SHOW3CUT.% Copyright 2001-2003 Kamil Anis, anisk@feld.cvut.cz% Dept. of Radioelectronics, % Faculty of Electrical Engineering% Czech Technical University in Prague% $Revision: 0.2 $ $Date: 2003/5/14 19:27:22 $% --% <additional stuff goes here>global ECHOname = 'SHOWLATT';[idt,tag] = iecho(name);[m,n] = size(latt);str2 = num2str(m);str3 = num2str(n);nopts = length(varargin) / 2;opts = reshape(varargin,[2 nopts])';ord1 = strmatch('Echo',opts(:,1));ord2 = strmatch('Style',opts(:,1));ord3 = strmatch('Labeling',opts(:,1));% Echoif ~isempty(ord1) % first check whether local option exists value1 = opts{ord1,2}; switch value1 case 'on' ech = 1; case 'off' ech = 0; otherwise disp(' '); disp([tag,'Invalid option for Echo property.']); disp([idt,'Possible values are ''on''|{''off''}.']); disp(' '); ech = 0; endelse if ~isempty(ECHO) % than check whether global option exists switch ECHO case 'on' ech = 1; case 'off' ech = 0; otherwise disp(' '); disp([tag,'Invalid option for Echo property.']); disp([idt,'Possible values are ''on''|{''off''}.']); disp(' '); ech = 0; end else % if there are no settings use the defaults ech = 0; % default value endend% Styleif isempty(ord2) % there's no such option style = 0; % default valueelse % there's relevant option style = opts{ord2,2};end% Labelingif isempty(ord3) % there's no such option labeling = 0; % default value label = repmat(' ',1,m);else % there's relevant option value3 = opts{ord3,2}; if ~isstr(value3) if ech disp(' '); disp([tag,'Invalid option for Labeling property.']); disp([idt,'Labeling must be a string.']); disp(' '); end return end switch value3 case 'none' labeling = 0; label = repmat(' ',1,m); case 'num' labeling = 1; label = num2str([1:m]'); otherwise labeling = 1; label = labelsstr; endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY BEGIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% when n is element within a set {1,2,3} go ahead...if (n == 1) | (n == 2) | (n == 3) newplot; set(gca,'XlimMode','auto','YlimMode','auto','ZlimMode','auto'); switch n case 1 dummy_axis = zeros(m,1); h = plot(latt(:,1),dummy_axis); xlabel('X'); t = text(latt(:,1),dummy_axis(:,1),label); case 2 h = plot(latt(:,1),latt(:,2)); xlabel('X'); ylabel('Y'); t = text(latt(:,1),latt(:,2),label); case 3 h = plot3(latt(:,1),latt(:,2),latt(:,3)); xlabel('X'); ylabel('Y'); zlabel('Z'); view(3); t = text(latt(:,1),latt(:,2),latt(:,3),label); end % some post-processing stuff... set(gcf,'Name',['SHOWLATT: ',str3,'D lattice, ',str2,' elements']); pbaspect([1 1 1]); daspect([1 1 1]); grid on; % setting plot margin to avoid element vanishing% get_lims = [xlim ylim zlim];% plotmrgn(get_lims); set(h,'LineStyle','none','Marker','o','LineWidth',2); % choosing desired plot style switch style case 0 set(h,'MarkerFaceColor','none','MarkerEdgeColor','r','MarkerSize',13); col = 'r'; case 1 set(h,'MarkerFaceColor','k','MarkerEdgeColor','none','MarkerSize',13); col = 'w'; case 2 set(h,'MarkerFaceColor','b','MarkerEdgeColor','none','MarkerSize',15); col = 'w'; case 3 set(h,'MarkerFaceColor','r','MarkerEdgeColor','none','MarkerSize',10); col = 'k'; case 4 set(h,'MarkerFaceColor','b','MarkerEdgeColor','none','MarkerSize',10); col = 'w'; case 5 set(h,'MarkerFaceColor','none','MarkerEdgeColor','g','MarkerSize',15); col = 'k'; case 6 set(h,'MarkerFaceColor','none','MarkerEdgeColor',... [165,200,255]/255,'MarkerSize',18); col = [165,200,255]/255; case 7 set(h,'MarkerFaceColor',[0,162,255]/255,'MarkerEdgeColor',... 'none','MarkerSize',15); col = 'w'; case 8' set(h,'MarkerFaceColor',[123,255,180]/255,'MarkerEdgeColor',... 'none','MarkerSize',15); col = 'k'; case 9 set(h,'MarkerFaceColor',[251,255,144]/255,'MarkerEdgeColor',... 'none','MarkerSize',15); col = 'k'; case 10 set(h,'MarkerFaceColor',[255,107,107]/255,'MarkerEdgeColor',... 'none','MarkerSize',15); col = 'w'; end if labeling == 1 set(t,'Color',col,'FontWeight','bold','HorizontalAlign',... 'center') % set(t,'FontName','Helvetica'); else set(t,'Visible','off'); end else if ech disp(' '); disp([tag,'Invalid dimension!']); disp([idt,'Dimension must be an integer within a set n = {1,2,3}.']); disp(' '); end returnend% axis off;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -