stelios loizidis asked . 2023-04-17

Select values based on datetime

Hello,
 
I have the matrix Values (1X2100) and the corresponding DateTime matrix with datetime data (1x2100 datetime). The values in Values matrix are hourly. I want to categorize the values of the Values table into 3 categories. I wrote the following codes for categorization,
 
[k1,i1]=find(Values<0);
[k2,i2]=find(0<=Values & Values<=80;
[k3,i3]=find(80<Values);

Based on the i1, i2 and i3 I created the following matrices,

Cat_Time_1=DateTime(i1);
Cat_Time_2=DateTime(i2);
Cat_Time_3=DateTime(i3);

Cat_Time_1 (1X30 datetime), Cat_Time_2 (1X290 datetime) and cat_Time_3 (1X1780 datetime)
 
But what happens is the following: For example, in Cat_Time_1 there is 04-Jan-2012 04:00 and in Cat_Time_2 there is 04-Jan-2012 16:00. Another example is in Cat_Time_2 there is 16-Jan-2012 07:00 and in Cat_Time_3 there is the 16-Jan-2012 02:00. What I want is the same dates that exist in Cat_Time_1 and Cat_Time_2 stay in Cat_Time_1 and leave Cat_Time_2. The same dates that exist in Cat_Time_1 and Cat_Time_3 should leave from cat_Time_3 and stay in Cat_Time_1, while the same dates that exist in Cat_time_2 and Cat_Time_3 should leave Cat_Time_2 and stay in Cat_Time_3.
After that, based on the dates that exist in each matrix (Cat_Time_1, Cat_Time_2 and Cat_Time_3), all the values must be selected from the Values matrix of prices that correspond to the date. (e.g. in Cat_Time_1 the first date is 04-Jan-2012. The first row of the cat1 matrix should contain the 24 values corresponding to this date. The same in the other cases). How are these done?

matrix , datetime ,

Expert Answer

Kshitij Singh answered . 2024-05-17 19:39:56

The very first thing you should do is put your data and timestamps in a timetable.
 
Once you do that, use retime to create a daily timetable, using your own custom aggregation function that returns 1, 2, or 3 according to your rules ("the same dates that exist in Cat_Time_1 and Cat_Time_2 stay in Cat_Time_1 and leave Cat_Time_2 ...", which I don't really understand but you should be able to write that function.
 
Now you have a list of days and what category they are in. Use dateshift on your original timetable to add a new variable that is the day timetamp, use join to combine that with the daily timetable, and select data from tyhat using the category number.
 
The custom function aside, this is just a few lines of code. No loops needed.


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.