cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Mathcad 15: printing output to text file as string

ptc-4441773
1-Newbie

Mathcad 15: printing output to text file as string

Much of my past experience has been in C, C++, etc where I can write my output directly to a text file. Is there a way I can send strings to a text file along with variables? I would like to be able print out my results from my program in order to debug my results.

For example, I have a matrix M that I would like to send to a text file along with sentences. Throughout the program I would like to append to the same text file.

4 REPLIES 4

In MC15, use the trace() function and open the debugging window.

Prime does not yet have the trace() function.


StuartBruff
23-Emerald III
(To:ptc-4441773)

Rehan Momin wrote:

Much of my past experience has been in C, C++, etc where I can write my output directly to a text file. Is there a way I can send strings to a text file along with variables? I would like to be able print out my results from my program in order to debug my results.

For example, I have a matrix M that I would like to send to a text file along with sentences. Throughout the program I would like to append to the same text file.

There are several file output functions and components ... look them up in Help. Here's an example (most of the output functions work on arrays rather than scalars or strings) in which I create an array that contains a list of the variables that I wish to output.

collab+-+12+10+07+file+output+01.jpg

One thing to note is that with Mathcad, provided you aren't dealing with arrays or other values that stretch over more than one page width (only a limitation in Mathcad Prime), then you could just evaluate the variables when you want (using 😃 and print the Mathcad worksheet (if on-screen inspection isn't feasible).

Play around with some of the functions ... the PRN format is readable but not as "obvious" as the Mathcad evaluation shown above:

// Datafile written by Mathcad

// 10/07/12 09:41:44

.MATRIX 0 0 3 2

"M" {1,0,2,2} "x" 9 "A" {2,0,2,2}

.MATRIX 1 0 2 2

1 2 3 4

.MATRIX 2 0 2 2

9 18 27 36

Stuart

Yes, it's better to do it through the debug window.

MathcadReportGraph_mini.jpg

MathcadReportGraph.png

MathcadReport.pdf

MathcadReport.xmcdz (rus)

When using the trace function to output to the trace window, my 11x11 matrix is not displayed with all values shown. Is there a way to have the trace window output the matrix with all values shown?

Announcements

Top Tags