Export Command Window to Excel

조회 수: 12 (최근 30일)
CMatlabWold
CMatlabWold 2020년 8월 11일
댓글: CMatlabWold 2020년 8월 12일
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');
CMatlabWold
CMatlabWold 2020년 8월 12일
It works - thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by