Turning data in time domain into percentage
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jake Bowd
am 8 Okt. 2019
Kommentiert: Peter Perkins
am 15 Okt. 2019
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 Kommentar
Peter Perkins
am 15 Okt. 2019
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.
Akzeptierte Antwort
Adam Danz
am 9 Okt. 2019
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 Kommentare
Adam Danz
am 9 Okt. 2019
Bearbeitet: Adam Danz
am 10 Okt. 2019
"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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!