What are "dimension names"?

51 Ansichten (letzte 30 Tage)
alpedhuez
alpedhuez am 19 Jun. 2022
Kommentiert: Peter Perkins am 21 Jun. 2022
I got an error message "Renaming dimension names is not supported using RENAMEVARS." What are "dimension names"? How can one rename "dimenion names"?
  3 Kommentare
alpedhuez
alpedhuez am 19 Jun. 2022
Bearbeitet: alpedhuez am 19 Jun. 2022
I just want to know what "dimenion names" are. https://www.mathworks.com/help/matlab/matlab_prog/changes-to-dimensionnames-property-in-r2016b.html do not seem to give an explanation.
code is just renamevars of the name of the first column of a table.
"Error using tabular/renamevars
Renaming dimension names is not supported using RENAMEVARS."
Image Analyst
Image Analyst am 19 Jun. 2022
Bearbeitet: Image Analyst am 19 Jun. 2022
Since you won't show us your code, or tell us what you want to do, about all I can say are that for a regular 2-D matrix, the dimension names are "rows" and "columns". For 3-D you can call the third dimension "slice" or "Z". For a table, the dimensions are also rows and columns but are also called height and width, and there are height and width to determine those. For a table, the columns also have names, like column 1 of a table might be 'Date" and column 2 might be "weight" or whatever.
Dimension names are not really renamed. They are what they are (e.g. rows and columns). However you can rename a column in a table (the name of the column -- the header string you see above the column), if that's what you were trying to do.
For a structure, the dimensions I guess would be the number of field names the structure has. fieldnames

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Steven Lord
Steven Lord am 19 Jun. 2022
Let me guess, you're trying to rename the Time of a timetable.
dt = datetime('today') + days(1:4).';
t = array2timetable(magic(4), 'RowTimes', dt)
t = 4×4 timetable
Time Var1 Var2 Var3 Var4 ___________ ____ ____ ____ ____ 20-Jun-2022 16 2 3 13 21-Jun-2022 5 11 10 8 22-Jun-2022 9 7 6 12 23-Jun-2022 4 14 15 1
t.Properties
ans =
TimetableProperties with properties: Description: '' UserData: [] DimensionNames: {'Time' 'Variables'} VariableNames: {'Var1' 'Var2' 'Var3' 'Var4'} VariableDescriptions: {} VariableUnits: {} VariableContinuity: [] RowTimes: [4×1 datetime] StartTime: 20-Jun-2022 SampleRate: NaN TimeStep: 1d CustomProperties: No custom properties are set. Use addprop and rmprop to modify CustomProperties.
t2 = renamevars(t, 'Time', 'Date')
Error using tabular/renamevars
Renaming dimension names is not supported using RENAMEVARS.
While Time looks like a variable, it's actually the name of the first dimension of t. You can use t.Time to get all of the row times, just like you can (if they can be concatenated into one array) use t.Variables to get all the data in the array.
See the description of DimensionNames in the Name-Value Arguments subsection under the Input Arguments section as well as the description of DimensionNames in the Properties section of this documentation page for more information about dimension names for a timetable.
This would work (but not in this Answers post, since MATLAB threw an error above.)
t.Properties.DimensionNames{1} = 'Date';
  3 Kommentare
alpedhuez
alpedhuez am 20 Jun. 2022
Yes you are right. But what is the rationale?
Peter Perkins
Peter Perkins am 21 Jun. 2022
What is the rationale of any of the names in tables? To give meaning to things that would otherwise be described as "1" etc.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Produkte


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by