MATLAB: Turning data in time domain into percentage

datapercentagetimetime series

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,

Best Answer

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.