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!