Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
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;
Solved! Go to Solution.
See if this works for you:
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
no mcad worksheet that I can see. What have you got so far and where does Mathcad get stuck?
Please find attachment. Please refer page 48(last page).
See if this works for you:
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