How to use for loop correctly and indexing my result?
1 回表示 (過去 30 日間)
古いコメントを表示
a = [1 1 1 0 0 0 0 1 0 1 0 1 1 0 0 1] ;
b = [1 1 1 0 1 0 0 0 1 1 1 0 0 0 0 1] ;
S = [a, a, a, a, a, a, a, a, a ,a;b, b, b, b, b, b, b, b, b, b];
x1 = S(1:1,:);
x2 = S(2:2,:);
L = 3;
for i = 3:160
x11 = [x1(i),x2(i)]
x12 = [x1(i-1),x2(i-1)]
x13 = [x1(i-L+1),x2(i-L+1)]
x14 = [1]
X1 = [x11 x12 x13 x14]
end
Hi this is my code. After I run it, it display the answer for x11, x12, x13, x14, and X1 directly with i = 3 to 160, a total of 158 sets of results. How to code such that i want to select my 3rd result to show only?
0 件のコメント
回答 (1 件)
madhan ravi
2020 年 5 月 31 日
Use ; at the end of each line inside the loop.
X1(3,:) % after the loop
6 件のコメント
madhan ravi
2020 年 5 月 31 日
Please illustrate with a short example with an expected result, so it's easy to understand the main goal.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!