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

How to import a two-column data and solve equation by using a while loop?

chuang-4
1-Newbie

How to import a two-column data and solve equation by using a while loop?

Dear all,

I am a beginner of using Mathcad 15 and I have a very basic question regarding to the data import and solving an equation. I try to simplify my questions: I have a text file containing two columns of data with column 1 is "a" and column 2 is "b". I would like to solve the equation a*x^2 - b = 0 to get x value. This means once I import (a0, b0) I have x0 export and so on so forth. I would like to export all x values into a file. Can someone please tell me how I can do this? Thanks a lot in advance.

Best regards,

Chien-Lung

1 ACCEPTED SOLUTION

Accepted Solutions

I built a simple example file.

View solution in original post

3 REPLIES 3
StuartBruff
23-Emerald II
(To:chuang-4)

You can use the file input and output components or you could use one of the File output functions.

For example, to output the x values, go the main menu and select Insert/Data/File Output.  This will bring up a dialog box thal allows you to specify the file format that you want (eg, tab delimited or comma seperated), and enter a file name.   When you finish with the dialog, it will create a file output "component" with a placeholder for the array name.  I've shown what the dialog box looks like below and an example of saving the array x.   If you want to read data, then you should choose Insert/Data/File Input, which will lead you through a similar process, the main difference being that the component's placeholder takes the form of a standard definition (:=) - see below for example, reading the x value file into a variable y.

Look up the various forms of file input/output function in Help.  The example below uses READFILE to copy the x value file into variable z:

Stuart

Thank you for the prompt help!!

I built a simple example file.

Top Tags