Skip to main content
1-Visitor
March 3, 2021
Solved

I want to perform below operations on arrays of 100000 rows

I want to perform below operations on arrays of 100000 rows. I used for loop and mathcad got hanged.

Is there any other ways to perform these operations?

Go1 and Go2 are arrays of 10000 rows.

The below code is of matlab and I want to write similar code in mathcad

if ( abs( Go1 - Go2 ) > 1.0 / ( RMAX + 700000 ) )

Rp = ( 1 + r2 - r1 - ( R2t * Go1 - R2b * Go2 ) ) / ( Go1 - Go2 ) - ( R0 + R1 );
Rp = abs(Rp);

x1 = +( R0 + R1 + R2t + Rp ) .* Go1 + r1;
y2 = -( R0 + R1 + R2b + Rp ) .* Go2 - r2;

else

Rp = ( 1 + r2 - r1 ) / ( 2 * Go1 ) - ( R0 + R1 + ( R2t + R2b ) / 2 );
Rp = abs(Rp);
if ( Go1 < 0.5 / ( RMAX + 700000 ) ); Rp = RMAX; end

x1 = 0.5 * ( 1 + r1 + r2 + Go1 * ( R2t - R2b ) );
y2 = 1 - x1;

LucMeekesAnswer
23-Emerald IV
March 3, 2021

See if this works for you:

LucMeekes_4-1614777664035.png

I hope I interpreted "+( R0 + R1 + R2t + Rp ) .* Go1" and "-( R0 + R1 + R2b + Rp ) .* Go2" correctly.

Worksheet (Prime4) attached.

Note that Rp, x1 and y1 are mostly calculated as arrays. It's only when the comparison of Go1 with a scalar value has to be made, indexing is needed. (Advice: Carefully read Werner's explanation about vectors, indexing and vector operations here https://community.ptc.com/t5/PTC-Mathcad/multiplying-a-variable-in-a-formula/m-p/716178#M194689 )

 

Success!
Luc

3 replies

14-Alexandrite
March 3, 2021

no mcad worksheet that I can see. What have you got so far and where does Mathcad get stuck?

Translate
1-Visitor
March 3, 2021

Please find attachment. Please refer page 48(last page). 

Translate
LucMeekes23-Emerald IVAnswer
23-Emerald IV
March 3, 2021

See if this works for you:

LucMeekes_4-1614777664035.png

I hope I interpreted "+( R0 + R1 + R2t + Rp ) .* Go1" and "-( R0 + R1 + R2b + Rp ) .* Go2" correctly.

Worksheet (Prime4) attached.

Note that Rp, x1 and y1 are mostly calculated as arrays. It's only when the comparison of Go1 with a scalar value has to be made, indexing is needed. (Advice: Carefully read Werner's explanation about vectors, indexing and vector operations here https://community.ptc.com/t5/PTC-Mathcad/multiplying-a-variable-in-a-formula/m-p/716178#M194689 )

 

Success!
Luc

Translate