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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Translate the entire conversation x

Sorting Complex Numbers

StuartBruff
23-Emerald IV

Sorting Complex Numbers

Reference https://community.ptc.com/t5/Mathcad/Sum-in-Mathcad-Prime/m-p/1035397/highlight/true#M218879

 

Following on from the discussion re minima and maxima of various Mathcad data types, I gave up on trying to fault-find my original (messy) complex sort worksheet, and present the following simplified Mathcad Prime 11 version for your edification.  It's based on merge sort.

 

2025 09 23 H.png

 

zv is the complex-valued vector to sort, and I've rerun the results in MATLAB.

.

Stuart  

5 REPLIES 5
Werner_E
25-Diamond I
(To:StuartBruff)

What am I missing?

Werner_E_1-1758667709640.png

 

 

Werner_E
25-Diamond I
(To:Werner_E)

A quick hack to fix the problem with 1-column matrices:

Werner_E_1-1758692285018.png

Werner_E_4-1758692767567.png

StuartBruff
23-Emerald IV
(To:Werner_E)

Yes, effectively the same solution.   Great minds ... 😈

 

Then I realised that, in terms of testing, I'm busy doing all the barking when I've got a perfectly good laptop that can do that for me:

 

2025 09 24 C.png

 

Stuart

2025 09 24 D.png

StuartBruff
23-Emerald IV
(To:Werner_E)

Hmm.  Yes, avoidable if we had the empty array, but never mind.  I snagged a couple of functions from my Express library.

 

Hopefully, the problem is now fixed, the code appears more elegant, and is ripe for conversion to Express.

 

2025 09 24 A.png

 

2025 09 24 B.png

 

Hopefully, I will test my worksheets more rigorously in future.  ( 🤣 )

 

Stuart

Announcements

Top Tags