Matlab: How to generate the time data

In summary, the conversation revolves around using MATLAB to generate time data for a data set of 2 days worth of normalized data with 96 data points total (48 per day). The data represents a normalized load of the UK, divided by the peak value to get a number between 0 and 1. The suggestion is to use the colon (:) operator to generate a vector of values. Mathworks provides extensive documentation on MATLAB and tutorials for beginners.
  • #1
hsydxhza
1
0
Hey everyone,
I'm a new starter of matlab, and I'm asked to generate the time data , for a data set of 2 days worth of normalised data with 96 data points total (48 per day)
0.605377319
0.592191368
0.583245509
0.575892748
0.576088821
0.57089287
0.556358913
0.560623514
0.579936766
0.650817382
0.723291096
0.818533859
0.881596039
0.925761623
0.933040857
0.958407882
0.967745889
0.975466288
0.978627975
0.976912331
Here are a part of data I got, and they represent a normalised load of the UK, i.e. divided all the power values by the peak value to get a number between 0 and 1.
Can anyone here help me with it?

Cheers
Clark
 
Physics news on Phys.org
  • #2
Welcome to PhysicsForums!

What do you mean by time data? Just elapsed seconds / minutes?

You'll need to generate a vector of values. If you want equal spacing, MATLAB allows you to conveniently generate these using the colon (:) operator. The following code generates a vector (list) of numbers from 0 to 24 (in increments of 1, the middle number):
>> hourVector = 0:1:24;

Mathworks provides quite extensive documentation on MATLAB at their website (as linked below in my signature). They also provide quite a nice set of tutorials if you're brand new to MATLAB (I don't know how the videos work, but the young ones seem quite fond of them these days, as opposed to the written tutorials which I learned on):
http://www.mathworks.com/help/techdoc/learn_matlab/bqr_2pl.html

Good luck!
 

Related to Matlab: How to generate the time data

1. How do I generate random time data in Matlab?

To generate random time data in Matlab, you can use the rand function along with the datenum function. First, generate a matrix of random numbers using rand. Then, use datenum to convert the numbers into a date format. For example: time_data = datenum(2021, rand(1,10), rand(1,10)) will generate 10 random dates in the year 2021.

2. How do I create a time vector in Matlab?

To create a time vector in Matlab, you can use the datetime function. This function allows you to specify the start date, end date, and frequency of the time vector. For example: time_vector = datetime('2021-01-01', '2021-12-31', 'daily') will create a time vector with daily intervals from January 1, 2021 to December 31, 2021.

3. Can I generate time data in specific time zones using Matlab?

Yes, you can generate time data in specific time zones using Matlab. You can use the datetime function with the TimeZone name-value pair to specify the desired time zone. For example: time_data = datetime('now', 'TimeZone', 'America/New_York') will generate the current time in the Eastern Time Zone.

4. How do I convert time data into a different time format in Matlab?

To convert time data into a different time format in Matlab, you can use the datestr function. This function allows you to specify the format you want the time data to be displayed in. For example: new_time_data = datestr(time_data, 'mm/dd/yyyy HH:MM:SS') will convert the time data into a string format with month, day, year, and time information.

5. Can I generate time data for a specific time period in Matlab?

Yes, you can generate time data for a specific time period in Matlab. You can use the datetime function with the Period name-value pair to specify the desired time period. For example: time_data = datetime('now', 'Period', 'hour') will generate the current time with hourly intervals.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
862
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Replies
3
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
Back
Top