How to store values of iterations
10 次查看(过去 30 天)
显示 更早的评论
I have a for loop with an if condition. I want to store all the values of 'i' for which the codition is met. Right now it only stores the last value of i.
for i=1:length(data)
x = i+1;
if i == length(data)
x = length(data);
end
if (magnitude_velocity(x,1)<0.01) && (magnitude_velocity(i,1)>0.01)
index = i;
end
end
0 个评论
采纳的回答
Wouter
2013-3-21
index = [];
for i=1:length(data)
x = i+1;
if i == length(data)
x = length(data);
end
if (magnitude_velocity(x,1)<0.01) && (magnitude_velocity(i,1)>0.01)
index = [index i];
end
end
1 个评论
Wouter
2013-3-21
And this is a bit shorter:
index = [];
for i=1:length(data)-1
if (magnitude_velocity(i+1,1)<0.01) && (magnitude_velocity(i+1,1)>0.01)
index = [index i];
end
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!