How can I separate and reorganize my data based on the value of one column?
7 次查看(过去 30 天)
显示 更早的评论
Hi,
I have datasets that were recorded at different temperatures and I would like to separate each run based on the temperature. I currently have the data stored as a table, with the following code as an example.
Temperature Field M
5.00269031524658 -70000.2578125000 -102.437914384298
5.00254058837891 -65000.2656250000 -102.369662975620
5.00252556800842 -60000.4570312500 -102.309273029622
299.999298095703 -45000.2773437500 -91.7405686900717
300.002136230469 -40000.2148437500 -91.6043709197009
300.003448486328 -35000.2109375000 -91.4478158278339
300.005432128906 -30000.3945312500 -91.2654950487313
In the future, I may have data at different or more temperatures, so I would like to make the code generalizable. I know I need to use a For loop and also include some kind of tolerance for the temperature points, as each one isn't an integer. I'd like to make it look like the following code.
Temp_1 Field_1 M_1 Temp_2 Field_2 M_2
Any help on this is appreciated!
0 个评论
回答(1 个)
Harsha Priya Daggubati
2020-3-16
Hi,
Do you want to create seperate tables for a given temperature range?
Assuming you want to create different tables for each temperature range, I am providing the following solution.
For sorting the rows based on Temperature column, 'sortrows' method will help.You can then create subtables by imposing threshold on the temperature column.
For Example, Lets assume your data is in T variable:
subTable = T(: , T.Temperature<10);
This creates a subtable of T with values in Temperature column less than 10.
sortrows Doc:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!