Turning data in time domain into percentage
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi,
I am looking to turn a table of data (namely the 'mot1' table in the .mat file attached) into percentages, Does anyone have suggestions?
Best wishes,
댓글 수: 1
Peter Perkins
2019년 10월 15일
Jake, not sure if this would make your data easier to manage, but it's possible to use mergevars to put, for example, all the pelvis variables into one (inner) table inside of your mot1 table. You'd end up with an outer table that had fewer variables, each of which was itself a table.
채택된 답변
Adam Danz
2019년 10월 9일
I'm guessing your time column represent a portion of the day (ie, hh:mm) and it's that column that you want to turn into a percentage.
datestr(mot1.time(1:5))
ans =
5×8 char array
' 6:36 AM'
' 6:47 AM'
' 7:00 AM'
' 7:12 AM'
' 7:23 AM'
in which case, they already are a percentage. Do you want to scale them from 0:100 instead of 0:1? It may be better to leave them in their original form if you want to use them as datetime values. But here's how to scale them to 0:100
mot1.time = mot1.time*100 % or mot1.time = round(mot1.time*10)
mot1.time(1:5)
ans =
27.5
28.333
29.167
30
30.833
If you want actual '%' symbols you'd have to convert them to strings | char arrays
mot1.time = strcat(num2str(round(mot1.time*100)),'%')
%or
mot1.time = cellstr(strcat(num2str(round(mot1.time*100)),'%'))
But again, they would be virtually worthless in that form if you're planning on using them for analysis.
If you need them as lables, you can always add an additional column to the table.
댓글 수: 2
Adam Danz
2019년 10월 9일
편집: Adam Danz
2019년 10월 10일
"The time column is the length of a recording"
Does that mean mot1.time are durations? In minutes? They appear to be montonically increasing as if they are time stamps (in what units?).
"in each file the time length of the recordings [will] be different and so I would like to standardise the time column to be out of 100"
Is the file you attached file #1? This file starts at mot1.time(1) = 0.275. In order to normalize it I'd need to know that max time across all files, if I'm understanding it correctly.
"once done for the time column I would be making all the other columns the same length as the newly modified time column."
I didn't understand this one.
Maybe an example would help explain the goal.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!