How can I compress a table
5 ビュー (過去 30 日間)
古いコメントを表示
I have an imported csv file. Containing a lot of rows How can I compress them so that al of the data of one year is stored in one row. (as in the picture below? I could not get the script from an much older matlab version running)
and what kind of type are the columns with the icon that looks like three sticky notes?
Kind regards Ellen
2 件のコメント
Christopher McCausland
2023 年 11 月 28 日
編集済み: Christopher McCausland
2023 年 11 月 28 日
Hi Ellen,
The best way forward is probably to share a few rows of your data. Could you also explain a little more how you are expecing the output to look like? Sharing the old code may help here too.
In terms of the three sticky notes, I beleive they are known as 'pages', all that is being symbolised is that you have multiple data points stored in one structure field and row i.e. a 8784x1 double rather than a signal value as in the year feild. It makes a bit more sense here: Page-wise matrix multiplication - MATLAB pagemtimes - MathWorks Switzerland read the "More About" for a nice diagrame.
Hope this helps,
Christopher
採用された回答
Stephen23
2023 年 11 月 28 日
編集済み: Stephen23
2023 年 11 月 29 日
"How can I compress them so that al of the data of one year is stored in one row. (as in the picture below?"
Your screenshot shows a non-scalar structure with fields 'year', 'month', etc.:
We can get such a structure by importing as a table and then a few simple manipulations on it:
T = readtable('KNMI310_1996-2023.csv')
U = varfun(@(v){v},T, 'GroupingVariables','YYYY')
S = table2struct(U) % take a look at S in the variable viewer.
0 件のコメント
その他の回答 (1 件)
Peter Perkins
2023 年 11 月 28 日
Here's another possibility, using rowfun, that returns a table containing tables, which maybe is easier to use than what you asked for:
T = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1554527/KNMI310_1996-2023.csv")
U = rowfun(@(MM,dd,HH,DD,FF,P){table(MM,dd,HH,DD,FF,P)},T, GroupingVariables="YYYY",OutputVariableNames="Data")
U.Data{1}
U.Data{1}.DD(1:5) % etc.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!