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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

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

rmarcelli
5-Regular Member

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

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.

 

 

 

10 REPLIES 10
LucMeekes
23-Emerald III
(To:rmarcelli)

Here's an example that should get you going:

LucMeekes_0-1587593179434.png

Prime4 file attached.

 

Success!

Luc

rmarcelli
5-Regular Member
(To:LucMeekes)

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.

LucMeekes
23-Emerald III
(To:rmarcelli)

Long time user....

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

 

Luc

rmarcelli
5-Regular Member
(To:LucMeekes)

No, sorry... This I do not remember because I used MATHCAD for many years, but not continuously.  

rmarcelli
5-Regular Member
(To:LucMeekes)

Hi, I studied the problem trying to use your solution. The loop works perfectly for your example, but actually my program includes a couple of loops where two variables (omega and Ho) change to have Tandelta(omega, Ho). I hope to use exactly these two variables as "indexes", unless to be forced in defining i,j-indexes normalizing the problem in some way.

I tried brutally to insert the WRITECSV statement with augment(omega, Tandelta), as you can see in the attached file, before beginning with the plots, but nothing is written...

Where is my error?

Thanks a lot for your patience

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

rmarcelli
5-Regular Member
(To:Fred_Kohlhepp)

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

rmarcelli
5-Regular Member
(To:rmarcelli)

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

Mathcad can help with units:

FredKohlhepp_0-1588005634978.png

 

rmarcelli
5-Regular Member
(To:Fred_Kohlhepp)

Sorry, I did not notice your last comment after you helped me in solving my problem...

Thanks a lot and thank you again.

 

Yours,  Romolo

Announcements

Top Tags