Hello Nick
From what I gather, you are trying to fit data to a curve using the Curve Fitter App and you are pre-processing the data to fit the row data using “rows2vars” function.
Curve Fitter App expects numeric data as the input for the ‘X data’ and the ‘Y data’ selection menus. For tables, it automatically identifies the valid columns. For ex. If the table ‘data’ is of the size 11x22 with all the columns having numeric data but column 11 having character data, the Curve Fitter App will let you select all the columns from the ‘data’ table except column 11.
Given that you can see columns from your variable ‘data’, here are some possible scenarios that might explain the behavior you have encountered:
- One of the columns of ‘data’ has entries of datatype ‘char’: In this case, when the table is converted using the “rows2vars” function, the conversion between ‘char’ and numeric datatypes is unsuccessful and the new table is formed with empty entries except for the row with ‘char’ entries. The following code snippet demonstrates this:
data = array2table(rand(11,22));
data.Var11 = repmat('a', 11, 1);
Tdata = rows2vars(data)
Tdata =
OriginalVariableNames Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 Var9 Var10 Var11
_____________________ ____ ____ ____ ____ ____ ____ ____ ____ ____ _____ _____
{'Var1' }
{'Var2' }
{'Var3' }
{'Var4' }
{'Var5' }
{'Var6' }
{'Var7' }
{'Var8' }
{'Var9' }
{'Var10'}
{'Var11'} a a a a a a a a a a a
{'Var12'}
{'Var13'}
{'Var14'}
{'Var15'}
{'Var16'}
- One of the columns of ‘data’ has entries of cell or string entries: In this case, the “rows2vars” converts all the entries into cells or strings. The following code snippet demonstrates this:
data = array2table(rand(11,22));
data.Var11 = repmat({'a'}, 11, 1);
columnDataTypes = varfun(@class, data, 'OutputFormat', 'cell');
disp('Data Types of All Columns of data:');
Data Types of All Columns of data:
fprintf('%s: %s\n', data.Properties.VariableNames{i}, columnDataTypes{i});
end
Var1: double
Var2: double
Var3: double
Var4: double
Var5: double
Var6: double
Var7: double
Var8: double
Var9: double
Var10: double
Var11: cell
Var12: double
Var13: double
Var14: double
Var15: double
Var16: double
Var17: double
Var18: double
Var19: double
Var20: double
Var21: double
Var22: double
columnTDataTypes = varfun(@class, Tdata, 'OutputFormat', 'cell');
disp('Data Types of All Columns of Tdata:');
Data Types of All Columns of Tdata:
fprintf('%s: %s\n', Tdata.Properties.VariableNames{i}, columnTDataTypes{i});
end
OriginalVariableNames: cell
Var1: cell
Var2: cell
Var3: cell
Var4: cell
Var5: cell
Var6: cell
Var7: cell
Var8: cell
Var9: cell
Var10: cell
Var11: cell
Kindly check the datatypes of the entries in the table ‘data’. Due to mismatch of datatypes, the resultant converted table ‘Tdata’ might not contain any numeric column and thus the Curve Fitter App does not identify its columns.
For further understanding, kindly refer to the following MathWorks Documentation:
- Refer to the ‘Select Data to Fit in Curve Fitter App’ section to understand the expected datatypes: https://www.mathworks.com/help/releases/R2023b/curvefit/data-selection.html
- “fit” function to programmatically fit data to a curve: https://www.mathworks.com/help/releases/R2023b/curvefit/fit.html
I hope you find the above explanation and suggestions useful!