Skip to main content
1-Visitor
April 22, 2020
Question

writing and reading data with MATHCAD PRIME 4.0 in a simple way

  • April 22, 2020
  • 2 replies
  • 4575 views

Hi, I am a user, sometimes occasional but now more continuous, of MATHCAD various releases from more than 20 years now. I have always problems in finding a simple way to produce a data file starting from the quantities I define in my programs.

As an example, I wrote a quite simple program using PRIME 4.0 to plot a quantity as a function of another (a magnetic loss vs frequency) using a bias magnetic field as an external loop. So far, z=z(x,y) where both x and y are changed in a loop with x=x1, x1+xstep, ..x2 and the same for y.

At the end I was able to plot z=z(x,yfixed), with several curves depending on the yfixed value, but if I want to export this quantity in a ascii file I am in trouble, because the explanations in the help are not easy to be followed. In particular, I need to produce a file where the first column is the frequency, and all the others are the z-values with different values for y (which I fix when plotting)

In the attached MATHCAD file, the table (file) I want to fill in is that composed by omega and by all the tandelta values depending on the magnetic field Ho.

Do you know any example I can use downloading it?

Thank you very much.

 

 

 

2 replies

23-Emerald IV
April 22, 2020

Here's an example that should get you going:

LucMeekes_0-1587593179434.png

Prime4 file attached.

 

Success!

Luc

rmarcelli1-VisitorAuthor
1-Visitor
April 24, 2020

Thank you very much.

I will try now to put your code in my program after transforming it to produce a real matrix with i,j-indexes. I am user since a lot of time, but every time a quite simple requirement like this is a bit troublesome in MATHCAD. Actually, to have data files corresponds to the requirement to obtain not only data for post processing but even for better plots for publications.

23-Emerald IV
April 24, 2020

Long time user....

Then you must remember that for a period MathSoft provided a light edition of Axum with Mathcad.

 

Luc

23-Emerald I
April 24, 2020

Luc's same idea, but with an i,j example.

rmarcelli1-VisitorAuthor
1-Visitor
April 26, 2020

Thanks again for your help, from both of you.

As I understood from your reply, I tried to mix two different possibilities in MATHCAD, and for this reason I was not successful.

Because of my previous background and experience, I preferred to define "functions" like z(x,y) to obtain also data to be written in a file. Now, I realized that to define a function is useful for plotting data directly in MATHCAD, but it is not so effective for obtaining correctly a matrix to be exported as a data file, where there should be a dependence on i,j-indexes and not on variables used for defining a loop.

I will re-write the program following your suggestions, avoiding to mix concepts and definitions that cannot work together.

As soon as I will have re-written the code I will share it with you.

 

Keep in touch,   Romolo

rmarcelli1-VisitorAuthor
1-Visitor
April 27, 2020

I ended the program successfully, writing it, as I told you, in a new way, with i,j-indexes and not using the function z(x,y), which is indeed more useful for plots.

Attached the final file, for everyone needing a routine for calculating the magnetic permeability tensor in magnetic material computations with PRIME 4.0.

 

Yours,   Romolo