matlab GOTO(排序) [英] matlab GOTO (sort of)
问题描述
为了进行调试,我认为如果在点击一个文件时会很有用图片 - 编辑器到一个特定的行。有人知道这是否可以?
我以为我可以实现像
A = [];
figure
plot(x)
A = ginput(1)
如果A〜= []
goto(指针,行)
end
问题是,只有在数字是制作。不是在分析结束时,我看看最终错误的数字。
换句话说:有没有办法去一个特定的行代码点击数字?
NB有关GOTO的实现,请参见( GOTO FileExchange )
尝试使用 opentoline
函数与回调结合使用。像
plot(1:10); %一个简单的图
set(gcf,'ButtonDownFcn',@(h,e)opentoline('YourFunctionName.m',LineNumber));
在这种情况下,当您点击图(而不是轴,或任何标签,但是m文件将在编辑器中打开指定的行。
如果要以编程方式确定行号,请执行以下
plot(1:10)
st = dbstack;
set(gcf,'ButtonDownFcn',@(h,e)opentoline(st(1).file,st(1).line-1));
I have a long script calling many other scripts that spit out a lot of figures.
For debugging purposes I think it would be useful if -when clicking on a picture- the editor goes to a specific line. Does anyone know if this is possible?
I thought I could implement something like
A=[];
figure
plot(x)
A=ginput(1)
if A~=[]
goto(pointer,line)
end
The problem is that it only would work only right after that the figure is made. Not at the end of the analysis when I take a look to the figures for eventual errors.
In other words: is there a way to go to a specific line of the code by clicking on a figure?
N.B. For an implementation of GOTO see (GOTO FileExchange)
Try using the opentoline
function in conjunction with a callback. Something like
plot(1:10); % A simple plot
set(gcf,'ButtonDownFcn',@(h,e)opentoline('YourFunctionName.m',LineNumber));
In this case, when you click on the figure (not the axis, or any labels, but the grey part of the figure) the m file will open in the editor to the line specified.
If you want to programmatically determine the line number then do the following
plot(1:10)
st = dbstack;
set(gcf,'ButtonDownFcn',@(h,e)opentoline(st(1).file,st(1).line-1));
这篇关于matlab GOTO(排序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!