Saving the wrong datenum value, but the original variable contains the correct one
이전 댓글 표시
Hello everyone,
I'm facing an odd problem. I'm temporally colocating data from different instruments in a range of ± 12h, to do so I convert date and time in datenum and use 'Find', it works perfectly. However, I just realize an oddity, when a colocation is found I save the datenum of both instruments in a new variable together with other data and the datenum of one of the two instruments is not saved correctly. I attach an image to show that values get saved differently and the lines I use to save the value in the final variable.
If I run seprately the 'datenum_RO(:,y').*ones(600,1)' part only, it gives me the right datenum value, however it saves it wrong in prof_ro. It looks like is not keeping the decimals. What should I say to let it keep them? It's doing it only for the datenum, and not for the other values.

y correspond to colum #10
prof_ro(var,1:600,1:14)= [j.*ones(600,1) datenum_RO(:,y').*ones(600,1) Lat_RO(:,y') Lon_RO(:,y')...
bangle(:,y') temp(:,y') pres(:,y') refr(:,y') density(:,y') spc_hum(:,y') ...
datenum_iasi(b,1).*ones(600,1) Lat_iasi(b,1).*ones(600,1) Lon_iasi(b,1).*ones(600,1) ...
SO2_iasi(b,1).*ones(600,1)];
댓글 수: 5
Peter Perkins
2019년 5월 3일
Are you certain this is not just a display issue?
Valeria Cigala
2019년 5월 6일
Guillaume
2019년 5월 6일
Well, you're doing something wrong. Without seeing your code we can't say what. However, this is troubling: I'm temporally colocating data from different instruments in a range of ± 12h, to do so I convert date and time in datenum. That task is so much easier to do with datetime.
Valeria Cigala
2019년 5월 6일
편집: Valeria Cigala
2019년 5월 6일
Peter Perkins
2019년 5월 9일
As stated, that seems impossible unless you are either assigning into an integer array (but that apparently can't be the case, because you're showing a screen shot of a double matrix in the variable editor), or you've left something out. If it's really happening, you should be able to set a breakpoint and demnonstrate what's happening with command window output.
Guillaume's advice is worth considering. If you are doing calendar arithmetic and time conversions, you will be much happier with datetime.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!