Info
この質問は閉じられています。 編集または回答するには再度開いてください。
For loop help needed
1 回表示 (過去 30 日間)
古いコメントを表示
Can anyone see a reason why when I implement the following for loop:
for ashift = 1:n
x = [x(:,1) - x(ashift) x(:,2) - x(n+ashift) ...
x(:,3) - x(2*n+ashift)];
x = circshift(x,rowshift)
rowshift = rowshift - 1;
end
For the instance when n = 4, the output comes in the order of n = 1, n = 2, n = 4, n = 3 (I have checked this many times with manual calclations.
I can't think of any reason why this should be happening. Any help would be greatly appreciated.
Kind regards, Tom
5 件のコメント
回答 (1 件)
Sean de Wolski
2013 年 11 月 12 日
Use the debugger!
- Put this in a script or function and save the file.
- Put a break point on the first line (click on the dash next to the line number)
- Run the file and use dbstep or the Step icon to step through the loop and investigate what is happening on each line during each iteration.
4 件のコメント
Sean de Wolski
2013 年 11 月 12 日
On each line run the line at the command prompt and figure out what each value is doing.
For example
x(:,1) - x(ashift) x(:,2) - x(n+ashift) x(:,3) - x(2*n+ashift)]
Notice I took the ';' off the end so it prints.
Not lets look inside at it
x(n+ashift)
Divide and conquer until you figure out what's going on.
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!