Outputting a variable (1*1) struct in txt file
1 view (last 30 days)
Show older comments
Hello everybody
I run the regression analysis and have got a varialble with reg [1*1 struct] I want to output this in a txt file but its giving me an error this is the out out
reg =
FitParameters: '-----------------'
PowerMatrix: [28x6 double]
Scores: [14152x28 double]
PolynomialExpression: [28x2 table]
Coefficients: [28x1 double]
yhat: [14152x1 double]
Residuals: [14152x1 double]
GoodnessOfFit: '-----------------'
RSquare: 0.6721
MAE: 0.0693
MAESTD: 0.0593
Normalization: '1-to-1 (Default)'
LOOCVGoodnessOfFit: '-----------------'
CVRSquare: 0.6684
CVMAE: 0.0696
CVMAESTD: 0.0600
CVNormalization: '1-to-1 (Default)'
Can anybody help me with this as save('X.txt...') is not working
2 Comments
Walter Roberson
on 21 Aug 2015
What format do you want for the output, taking into account that part of the data involves a 14152 x 28 matrix ?
Answers (1)
Walter Roberson
on 21 Aug 2015
Xls might not make sense unless you use one Sheet per variable.
I suggest looping over the fields of the structure. For each write out the fieldname then the class() of the data then the array dimensions all on one line. Next line write the values out row by row, delimited, all columns on each line. For 2d arrays the number of rows in the file would match the number of rows in the matrix. You only use 2d in your sample output.
With this kind of arrangement, the heading for each variable tells you how many lines of data follow so you can gulp them all in in one textscan call or otherwise easily seek for the line you need.
2 Comments
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!