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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

I want to perform below operations on arrays of 100000 rows

SK_9833315
5-Regular Member

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;

1 ACCEPTED SOLUTION

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

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

View solution in original post

3 REPLIES 3
JXBWk
13-Aquamarine
(To:SK_9833315)

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

SK_9833315
5-Regular Member
(To:JXBWk)

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

LucMeekes
23-Emerald III
(To:SK_9833315)

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

Top Tags