How to use for loop correctly and indexing my result?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
madhan ravi
on 31 May 2020
Use ; at the end of each line inside the loop.
X1(3,:) % after the loop
6 Comments
madhan ravi
on 31 May 2020
Please illustrate with a short example with an expected result, so it's easy to understand the main goal.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!