在使用键盘输入进行调试时,我希望能够跳过 MATLAB 中几行代码的执行
While debugging with an input from the keyboard, I want to able to skip the execution of a few lines of code in MATLAB
目前我正在尝试调试这段代码摘录:
if (white_flag == 1)
keyboard;
imshow(rl_img);
N = N+1;
times(times_index,1) = index;
while(white_flag == 1)
imshow(rl_img);
index = index+1;
%%% If statement for when the loop has run out
if (index >= frames)
break
end
%%% Initial Image Pre-Processing
rl_img = ones(mod_height,width);
pre_rl_img = medfilt2(vreader.read(index));
for i = 1:mod_height
for j = 1:width
rl_img(i,j) = pre_rl_img(i,j);
end
end
white_flag = detect_white( rl_img, white_flag );
end
times(times_index,2) = index;
times_index = times_index+1;
else
index = index+ 1;
end
现在,如您所见,调试键盘输入调用 keybaord
在第二行。虽然这使我能够有效地查看程序执行的每个步骤,但我不明白如何跳过下面的部分:
for i = 1:mod_height
for j = 1:width
rl_img(i,j) = pre_rl_img(i,j);
end
end
这是一张相当大的图片(rl_img
),所以在我手动草草代码的同时等待键盘输入浪费了很多时间。有人可以告诉我如何在调试程序时跳过这些代码行的用户输入执行吗?
请不要犹豫,问我任何可以澄清这个问题的问题。感谢您的所有回答!
答案很简单:
你设置断点在冗长的循环之后,
当您决定 运行 自动执行所有剩余的循环直到您刚刚设置的断点时,按 [F5](继续)。
这假定您在普通 MATLAB 中调试代码 IDE。
如果我对你的问题的理解正确,你不想逐步执行每个循环迭代。
您可以跟随 或者您可以通过将光标放在循环之后的某处来避免创建额外的断点
并点击
在编辑器的调试面板上。
目前我正在尝试调试这段代码摘录:
if (white_flag == 1)
keyboard;
imshow(rl_img);
N = N+1;
times(times_index,1) = index;
while(white_flag == 1)
imshow(rl_img);
index = index+1;
%%% If statement for when the loop has run out
if (index >= frames)
break
end
%%% Initial Image Pre-Processing
rl_img = ones(mod_height,width);
pre_rl_img = medfilt2(vreader.read(index));
for i = 1:mod_height
for j = 1:width
rl_img(i,j) = pre_rl_img(i,j);
end
end
white_flag = detect_white( rl_img, white_flag );
end
times(times_index,2) = index;
times_index = times_index+1;
else
index = index+ 1;
end
现在,如您所见,调试键盘输入调用 keybaord
在第二行。虽然这使我能够有效地查看程序执行的每个步骤,但我不明白如何跳过下面的部分:
for i = 1:mod_height
for j = 1:width
rl_img(i,j) = pre_rl_img(i,j);
end
end
这是一张相当大的图片(rl_img
),所以在我手动草草代码的同时等待键盘输入浪费了很多时间。有人可以告诉我如何在调试程序时跳过这些代码行的用户输入执行吗?
请不要犹豫,问我任何可以澄清这个问题的问题。感谢您的所有回答!
答案很简单:
你设置断点在冗长的循环之后,
当您决定 运行 自动执行所有剩余的循环直到您刚刚设置的断点时,按 [F5](继续)。
这假定您在普通 MATLAB 中调试代码 IDE。
如果我对你的问题的理解正确,你不想逐步执行每个循环迭代。
您可以跟随
并点击