Adding elements into array in for loop

3 次查看(过去 30 天)
Hello everyone, I have a problem with my project, which is little bit complicated, so that I describe it to you briefly:
I have an array named Shody{99*1} cell. I've used Kalman filter and region validation to find the trajectory.
For example, to be simple, I consider Shody{1} = [9 7], Shody{2} = [6 8; 7 7], Shody{3} = [7 4], Shody{4} = [4 8; 7 9], Shody{5} = [8 3]. After using filtering algorithm I will get the trajectorie = [9 7 7 4 8 3], you can see it is like a chain from Shody{1} to Shody{5} ([9 7] [7 7] [7 4] [4 8] [8 3]). With for loop (i = 1:length(Shody)), I just want to get:
When i = 1 => Trajectory = [9 7];
When i = 2 => Trajectory = [9 7 7];
When i = 3 => Trajectory = [9 7 7 4];
When i = 4 => Trajectory = [9 7 7 4 8];
When i = 5 => Trajectory = [9 7 7 4 8 3] ..... up to 99
But I used Trajectory = cat(1, Shody{1}, k) and got a problem like that:
When i = 1 => Trajectory = [9 7];
When i = 2 => Trajectory = [9 7 7];
When i = 3 => Trajectory = [9 7 4];
When i = 4 => Trajectory = [9 7 8];
Can anyone give me some hints, please!
I will give you my file, so that you could understand what I mentioned. It is little complicated, so I am afraid whether I can make you understand my problem or not.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by