for loop for two particular days of a week
Show older comments
Hi,
I am trying to make a for loop counting each monday and thursay for some period of time like one year. I want to start with coming Monday, 08/08/2022 counting it as 1 then Thursday 4, next monday 8, next Thursday 11 and upto a total of 100 Monday plus Thursday.
The vector looks like this V=[1 4 8 11 ......................]. It is going to be inconvinent to write all elements of this vector if a long period of time like 2 years choosen. I am trying to use a for loop and generalize above vector.
Any suggestions will be highly apperciated.
Thanks
Dharma
Accepted Answer
More Answers (1)
Voss
on 7 Aug 2022
n_weeks = 50;
vec = reshape((0:n_weeks-1)*7+[1;4],1,[]);
1 Comment
Dharma Khatiwada
on 8 Aug 2022
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!