struct for loop syntax difficulty
显示 更早的评论
Not sure what I'm doing wrong with the following loop:
for p=66:1:95;
Site(p).Day = Data((Data(:,4) == p),:)
end
I want Site(p) to contain all data from only the days (in column 4) that I am looking for, which should give a 1x29 struct, but at the moment Site(p) is a 1x95 struct where the first 65 entries are blank ([]). I assume the problem is in the first line, but when I make p the correct size (eg p=1:29) I get an error message about dimension mismatch. Also, if I set another vector, eg n=95-66 and p=1:n, I get the same error message. I can't see what I'm doing wrong.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!