How to use for loop correctly and indexing my result?
조회 수: 2 (최근 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!