how to modify a structure?

Hello. I initialize (instantiate) a structure like this:
YourStruct = struct(...
'Date', {cell(2208,1)}, ...
'Hour', {zeros(2208,1)}, ...
'DryBulb', {zeros(2208,1)}, ...
'DewPnt', {zeros(2208,1)}, ...
'SYSLoad', {zeros(2208,1)}, ...
'NumDate', {zeros(2208,1)});
'Date' has 92 days, and 'Hour' has 24 hours, from 1 to 24. How can I express 'Date' and 'Hour' in serial date numbers and how do I present these serial date numbers in 'NumDate'? Thank you.

7 件のコメント

Image Analyst
Image Analyst 2012 年 9 月 16 日
Please format properly (as Code).
UPT
UPT 2012 年 9 月 16 日
please Image Analyst,can you be more specific?(sorry but i'm a begginer in MATLAB).thanks
UPT
UPT 2012 年 9 月 16 日
thank for your suggestions Walter Robinson..:)
Walter Roberson
Walter Roberson 2012 年 9 月 16 日
Please go back and edit your original posting to mark-up the code there.
Note: there is no "i" in my username.
UPT
UPT 2012 年 9 月 16 日
編集済み: Oleg Komarov 2012 年 9 月 16 日
sorry again for my mistakes Walter Roberson: here is my new post:
data = struct('Date', {cell(2208,1)}, 'Hour', {zeros(2208,1)}, 'DryBulb', {zeros(2208,1)}, 'DewPnt', {zeros(2208,1)}, 'SYSLoad', {zeros(2208,1)}, 'NumDate', {zeros(2208,1)});
'Date' has 92 days and 'Hour' has 24 hours,from 1 to 24.how can i express 'Date' and 'Hour' in serial date numbers and to present these serial date numbers in 'NumDate'?
Walter Roberson
Walter Roberson 2012 年 9 月 16 日
Blank line before and after the code. Indent the code.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 9 月 16 日

0 投票

NumDate = Data.Date + (Data.Hour - 1) / 24;

5 件のコメント

Walter Roberson
Walter Roberson 2012 年 9 月 16 日
Wait -- what exactly does the Date cell contain?
UPT
UPT 2012 年 9 月 16 日
Date cell contains the dates from 1 July 2011-31 September 2011
Walter Roberson
Walter Roberson 2012 年 9 月 16 日
As strings? If so then use datenum() to convert them to serial date numbers and add (Hour-1)/24
UPT
UPT 2012 年 9 月 17 日
for each day i want to have 24 date serial numbers (a date serial number for each hour).could please you tell me how i can do that?...note:im a new user in matlab and i make some basic mistakes,so dont be upset if i dont understand all what you say..anyway,this is the fourth time you help me and im very grateful to you..:)
Walter Roberson
Walter Roberson 2012 年 9 月 17 日
Your Hour field is the same length as your Date field, which suggests you want exactly 1 hour conversion for each Date converted, rather than wanting to create 24 hour conversions for each Date converted.
data.NumDate = datenum(Data.Date) + (Data.Hour - 1) / 24;
except that you might need to add an additional parameter to datenum() in order to indicate the date format.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

質問済み:

UPT
2012 年 9 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by