matlabtext-capture

How do I capture the output from the "present" function and store it in a string


In Matlab, I have a IDPOLY object which I wish to "present" and store the resulting text in a text file.

eg if a is an IDPOLY object and I do

>> present(a)

I get

Discrete-time IDPOLY model: A(q)y(t) = B(q)u(t) + e(t)                
A(q) = 1 - 1.31 q^-1 + 0.2425 q^-2 - 0.431 q^-3 + 0.4987 q^-4         

B1(q) = 0.01357 + 0.04006 q^-1 - 0.04489 q^-2 + 0.007757 q^-3         
              - 0.1761 q^-4 + 0.06396 q^-5 - 0.2874 q^-6 + 0.3835 q^-7


B2(q) = -0.006397                                                     

Estimated using ARX with focus on data set iddata_est_shift           
Loss function 0.0617185 and FPE 0.061879                              
Sampling interval: 0.025                                              
Created:       24-Nov-2010 13:05:10                                   
Last modified: 24-Nov-2010 13:06:56   

Does anyone know how to capture this text as I'd like to write it to a text file in a log file. There are no returned arguments from present.


Solution

  • I've found the evalc() command which does exactly what I need.

    evalc
    
    Evaluate MATLAB expression with capture
    Syntax
    
    T = evalc(S)
    [T, X, Y, Z, ...] = evalc(S)
    

    and pass the expression as a string.