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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Falsely read complex numbers from a textfile

TV_kmi
3-Newcomer

Falsely read complex numbers from a textfile

I am using Mathcad Prime Release 9.0 and Datecode9.0.0.0

Hello.
When reading complex numbers from a text file (1 complex floating point value per line) into a vector, the following phenomenon appears: From the samples 500, 1000, 1500, ... (sample counting 0, 1, 2, ...) only the real part enters into the vector. I searched the vicinity of sample 500 for special characters that are invisible on the screen, but could eventually cause skipping the imaginary part during the reading procedure. I didn't find any special character except 0D and 0A (hex) "carriage return", "line feed"

Here are the errors that I faced
No error message or warning

ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:TV_kmi)

Ah, I see you are using Prime, and probably used the READFILE function, with "delimited" as the second argument.

Guess there's a bug in that function:

LucMeekes_0-1692949273081.png

You should consider reporting that bug.

Unfortunately READPRN is not capable (anymore) to read such files. Seems like PTC managed to ruin that function going from Mathcad to Prime:

LucMeekes_1-1692949375371.png

But there's a work-around. If you edit the .txt file with notepad, replace all + with a space character and all i with nothing and save the result (as a text file with e.g. extension ".PRN" instead of txt),  you can read this file with READPRN. You get a matrix with two columns as I showed earlier, from which you can reconstruct the array of complex values.

 

Success!

Luc

View solution in original post

5 REPLIES 5
VladimirN
24-Ruby II
(To:TV_kmi)

Please upload your text file here.

TV_kmi
3-Newcomer
(To:VladimirN)

The textfile is named "224015_TFHF_sm_trunc300Hz.txt". No header, One column, One complex number per line.

LucMeekes
23-Emerald III
(To:TV_kmi)

Ah, I see you are using Prime, and probably used the READFILE function, with "delimited" as the second argument.

Guess there's a bug in that function:

LucMeekes_0-1692949273081.png

You should consider reporting that bug.

Unfortunately READPRN is not capable (anymore) to read such files. Seems like PTC managed to ruin that function going from Mathcad to Prime:

LucMeekes_1-1692949375371.png

But there's a work-around. If you edit the .txt file with notepad, replace all + with a space character and all i with nothing and save the result (as a text file with e.g. extension ".PRN" instead of txt),  you can read this file with READPRN. You get a matrix with two columns as I showed earlier, from which you can reconstruct the array of complex values.

 

Success!

Luc

LucMeekes
23-Emerald III
(To:TV_kmi)

What did you use to read the file.

I used READPRN, resulting in a 2 column matrix, the first column contains the real parts, the second column contains the imaginary parts:

LucMeekes_1-1692944673915.png

LucMeekes_2-1692945106930.png

 

Success!
Luc

 

MichaelW
17-Peridot
(To:TV_kmi)

This issue has been reported to PTC R&D to determine how to resolve the issue

 

Status:

CS401987 Reading complex numbers from a text file (1 complex floating point value per line) into a vector using READFILE() or READTEXT() works fine, except that lines 500, 1000, 1500, etc. get just the real part, miss the complex part in Mathcad Prime

Announcements
Top Tags