How to judge the duplicate value of the previous loop and the current loop in the loop
1 次查看(过去 30 天)
显示 更早的评论
a = [201101 201107 201201 201207 201301 201307 201401 201407 201501 201507]
for k = 1:2
if k =mod(k,2)==1
index =(1:5)
year = a(index)
else k = mod(k,2)==0
year = index =(2:6)
end
how can find repeat value a(index(2:5))
is any way to detect or find out the existence of these duplicate values
0 个评论
回答(1 个)
David Hill
2022-5-4
Not sure what you are asking. Of course there are going to be repeated values in the year rows. You need to explain better with an example.
a = [201101 201107 201201 201207 201301 201307 201401 201407 201501 201507]
for k = 1:2
if mod(k,2)==1
year(k,:) = a(1:5);
else
year(k,:) = a(2:6);
end
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!