📄 displayres.m.txt
字号:
function DisplayRes(DR,m,g)
% DisplayRes(DR,m,g)
% Display the resistor network, with heights given by Green's function g
% if supplied
nnps = round(sqrt(size(DR,1))); % number of nodes per side
LineWidth = 10*11/nnps;
[ni,mi,ri]=find(DR);
nr = length(m.Resistances); %number of resistances in model
rinds = interp1(m.Resistances,1:nr,ri,'nearest'); % colour index for each resistor
gmap = gray(nr+1); % we won't use gmap(end,:) which is white
gmap = [0 0 0;0 0 1]; % colours for demo
hold off
if nargin == 3
% g supplied so make 3-d plot
for ii=1:length(ni)
[ys,xs]=ind2sub([nnps nnps],ni(ii));
[ye,xe]=ind2sub([nnps nnps],mi(ii));
plot3([xs xe],[ys ye],[g(ni(ii)) g(mi(ii))],'LineWidth',LineWidth,'Color',gmap(rinds(ii),:));
hold on
end
else
% 2-d plot
for ii=1:length(ni)
[xs,ys]=ind2sub([nnps nnps],ni(ii));
[xe,ye]=ind2sub([nnps nnps],mi(ii));
plot([xs xe],[nnps+1-ys nnps+1-ye],'LineWidth',LineWidth,'Color',gmap(rinds(ii),:));
if ii == 1, hold on, end
end
axis([0 nnps+1 0 nnps+1]), axis('equal')
% h=gca; set(h,'YTickLabel',nnps+1-get(h,'YTick')); % set the ylabel to show array-style indexing
h=gca; set(h,'YTick',[],'XTick',[]); % just turn off the ticks
end
%hold off
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -