day and night from lat, long, time?

조회 수: 9 (최근 30일)
Nina Schuback
Nina Schuback 2020년 4월 5일
답변: Meysam Mahooti 2021년 5월 26일
I have a vector of latitude, and vector of longitude, and a vector of UTC time.
Is there a simple way to determine whether or not it is day or night at each point? Just a simple 0,1 kind of answer?
  댓글 수: 1
James Tursa
James Tursa 2020년 4월 5일
Convert it to a pointing vector and then find the angle between that and the Sun pointing vector. Do you have a Sun position function?

댓글을 달려면 로그인하십시오.

채택된 답변

Nina Schuback
Nina Schuback 2020년 4월 7일
Thank you for the replies!
I ended up using the sunsetsunrise.m function which gives me sunset and sunrise in UTC!

추가 답변 (2개)

Ameer Hamza
Ameer Hamza 2020년 4월 5일
If you have the Mapping toolbox, you can use timezone(): https://www.mathworks.com/help/map/ref/timezone.html to find the hour offset from the UTC given the longitude value.
From the offset value, you can convert the UTC to the local time and based on your threshold, whether it is day or night. Or you can also use datetime() function to convert the UTC to the local time.

Meysam Mahooti
Meysam Mahooti 2021년 5월 26일
https://www.mathworks.com/matlabcentral/fileexchange/60157-sunrise-sunset?s_tid=srchtitle

카테고리

Help CenterFile Exchange에서 Cartesian Coordinate System Conversion에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by