Export Command Window to Excel

9 次查看(过去 30 天)
Hi, I am pasting part of my code:
X = [PRCP Catch Back Manhole Break];
y = Street;
b4_default = stepwisefit(X,y)
%mdl10001 = fitglm(dsa, modelspec, 'Distribution', 'poisson');
outdata = b4_default;
writematrix(outdata, outfile);
This is what appears in the command window:
Initial columns included: none
Step 1, added column 3, p=3.45962e-15
Step 2, added column 4, p=1.30783e-07
Step 3, added column 1, p=0.00259678
Step 4, added column 2, p=0.00921344
Final columns included: 1 2 3 4
{'Coeff' } {'Std.Err.'} {'Status'} {'P' }
{[0.2564]} {[ 0.0967]} {'In' } {[ 0.0082]}
{[0.2890]} {[ 0.1106]} {'In' } {[ 0.0092]}
{[0.1702]} {[ 0.0477]} {'In' } {[3.9479e-04]}
{[1.0324]} {[ 0.1974]} {'In' } {[2.4544e-07]}
{[0.7337]} {[ 2.0668]} {'Out' } {[ 0.7228]}
b4_default =
0.2564
0.2890
0.1702
1.0324
0.7337
By the way I wrote the code, only this appears on the exported spreadsheet.
b4_default =
0.2564
0.2890
0.1702
1.0324
0.7337
Yet, I want the whole message to appear in the spreadsheet, the columns of "Status" and "P", especially.
Thanks!

采纳的回答

Walter Roberson
Walter Roberson 2020-8-11
You can use evalc() to capture the text that would be emitted by a computation.
The result will be a character vector with included newline characters, which is perfect if you want to fopen() / fwrite() / fclose(). But in some situations you might want to use strsplit() or regexp(S, '\n', 'split')
  3 个评论
Walter Roberson
Walter Roberson 2020-8-12
编辑:Walter Roberson 2020-8-12
msgs = evalc('b4_default = stepwisefit(X,y)');
msgs2 = evalc('b4_default');

请先登录,再进行评论。

更多回答(0 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by