identpt.m

来自「细胞生长结构可视化工具箱-MATLAB Toolbox1999.zip」· M 代码 · 共 43 行

M
43
字号
% Allow user to identify a point by clicking it with the mouse
% Gives Visual coordinates and actual coordinates

function identpt(filename)

eval(['load ', filename]);

figure(1);
clf;
plotv2;

cont=1;
title('Left click on point to be identified. Right click to end.');
while cont == 1
	

	[X,Y,Button] = ginput(1);
	if Button == 2
		cont = 0;
		break;
	end
	figure(1);
	clf;
	plotv2;

	% Compute distances to nodes from pt
	dis=zeros(size(wvis,1),1);
	for i=1:size(wvis,1)
		dis(i) = norm([X,Y]-wvis(i,:));
	end
	[minval,s] = min(dis);
	
	visc = [ num2str(wvis(s,1)) ', ' num2str(wvis(s,2))];

	actc=[];	% Actual coordinates
	for i=1:n
		actc = [actc, num2str(w(s,i)), ', '];
	end

	title(actc);
	text(wvis(s,1),wvis(s,2),visc,'Color','red');
	drawnow;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?