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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Loop through matrix values in Mathcad

NM_10165576
8-Gravel

Loop through matrix values in Mathcad

Hello everyone,
in the attached file below, fourth column of matrix I is d1 values.
I want to loop through each d1 values and get R as a matrix.
could someone help me here
attached mathcad 10 file.

1 ACCEPTED SOLUTION

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

I think you want d1 to be the 5th column of matrix I, the one with index 4 (because counting starts at 0).

Well, here goes:

LucMeekes_0-1724242978369.png

And read my extended first answer...

 

Success!
Luc

View solution in original post

6 REPLIES 6
LucMeekes
23-Emerald III
(To:NM_10165576)

If you just want the 4th column values of the matrix I, then you can do that using the column operator:

LucMeekes_0-1724240805721.png

Look in the operators panel for the column operator, or type [Ctrl-c] after the I.

Note that (by default) matrix indexing starts at 0, so the fourth column has index 3.

If you want the function V(d1) applied to that result, then do:

LucMeekes_0-1724241663924.png

Note that you have to vectorise the expression (the arrow above V(I<3>)). The vectorise operator is also found on the operators panel. Its shortcut is [Ctrl-Shft-^].

 

Your function R doesn't do what you might think:

it assigns 0 to i, then loops assigning sequentially, each of the values of the matrix I to VED.

Then within the loop, you assign the full matrix to a row vector with those four variable names.

This means that x gets the value 0 m, Ast gets the value 0 cm2, ...., d1 gets the value 0 cm and n1 gets the value 0.

Note that these (very same!) values are assigned 30 times, because I has 30 elements.

Next thing in the loop is that you re-assign V(d1) to VED, overwriting the initial value of VED.

Now d1 is 0 cm (every time !), and through the function V() that results in 10 mm = 1 cm.

Last thing in the loop is you increase i with 1 (for no use, because you never use its value).

After the loop you return VED.

Well, that's 10 mm = 1 cm,

 

Success!
Luc

i think you understood it wrong
i want R values as matrix, which depends on fourth column of Matrix I. 

Hi,

MartinHanak_0-1724242893857.png

 


Martin Hanák
LucMeekes
23-Emerald III
(To:NM_10165576)

What should that matrix R look like, then?

What do i do, if i want to use two parameter from I.
example i want to use the values of fourth and fifth column of I( which are d1 and n1 respectively).

NM_10165576_0-1724242490100.png

 

LucMeekes
23-Emerald III
(To:NM_10165576)

I think you want d1 to be the 5th column of matrix I, the one with index 4 (because counting starts at 0).

Well, here goes:

LucMeekes_0-1724242978369.png

And read my extended first answer...

 

Success!
Luc

Top Tags