How to insert zeros in a data returns
이전 댓글 표시
I have a data with two variables: dates and returns. These two variables don't include the festivities, i'd like to insert zeros in the returns in those days. Is there anyone who can help me?
댓글 수: 12
Lbuni
2019년 6월 5일
Adam Danz
2019년 6월 5일
Could you provide an example of what you'd like to do?
Adam Danz
2019년 6월 5일
Yes, it's more understandable.
What format are you "Dates"? Are they datetime? Are they strings?
class(Dates) = ?
Lbuni
2019년 6월 5일
If you import them as datetime, you can name that variable 't' (for now) and skip this line of code from my answer:
t = datetime(Dates,'InputFormat','yyyy-MM-dd');
If you continue to have problems, please attach a sample of data instead of me guessing what you're working with.
Lbuni
2019년 6월 5일
Adam Danz
2019년 6월 5일
The csv file is corrupted (when I opened it it was gibberish). Anyway, see my updated answer; at the bottom is a low-level solution that doesn't involve any newer matlab features.
Lbuni
2019년 6월 5일
Adam Danz
2019년 6월 5일
I just updated my answer to fix a mistake in my date formats. I used capital MM (minutes) instead of lowercase mm (months). Fixed (I tested it with your data).
Lbuni
2019년 6월 5일
Adam Danz
2019년 6월 5일
Eureka!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!