Hi all; I've written a program including two loops and I want to debug it using "keyboard " command.
for n=1:1000
for qq=1:100
tsd (n,qq)= rand(1);
keyboard
end
end
I want to see the "tsd " values just in "n=10 " and "qq=50, 70; 89" . How can I do this using "keyboard" and "return" commands. I look forward to see your reply,

 채택된 답변

per isakson
per isakson 2012년 4월 6일
편집: per isakson 2014년 3월 2일

1 개 추천

Why do you want to use KEYBOARD? That's not the best way - in my opinion. Thus, I would:
  1. Put the code in a function.
  2. Use conditional breakpoints
However, try to replace the line "keyboard" by
if n==10 && ( qq==50 || qq==70 || qq==89 )
keyboard
end

추가 답변 (2개)

per isakson
per isakson 2014년 3월 1일

0 개 추천

Here are some links on debugging in Matlab
Alex
Alex 2014년 9월 30일
편집: per isakson 2014년 9월 30일

0 개 추천

How do i fix this?
for i = 1:x_max
for i = 1:y_max
if(forests(i,j) == 1) %Plot Green grass
rectangle ('position',[i-0.5,j-0.5,MapRes,MapRez],'FaceColor',ForColor)
hold on
end
getting this error
if(forests(i,j) == 1) %Plot Green grass

댓글 수: 1

Alex
Alex 2014년 9월 30일
sorry this is the error: Subscript indices must either be real positive integers or logicals.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Desktop에 대해 자세히 알아보기

태그

질문:

som
2012년 4월 6일

편집:

2014년 9월 30일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by