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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Usage of for loop

ptc-4888566
1-Newbie

Usage of for loop

Please find the below example:

I need to evaluate Cm which is a 6*6 matrix..im not able to find the right syntax,could you please help.

for loop.jpg

2 REPLIES 2

Prithivirajan Veerappan wrote:

Please find the below example:

I need to evaluate Cm which is a 6*6 matrix..im not able to find the right syntax,could you please help.

I'm not sure what your problem is from the image. Assuming that it's being able to use the arrays within the rest of the worksheet, then you need to assign the results of the for loops (the matrices) to appropriate variables. Any variable created within a program using the left arrow operator is local to that program and doesn't exist outside it.

It's also helpful if you post the worksheet rather than just an image. There are a few Mathcad constructs that look similar but are completely different in nature (eg, array index versus literal subscript). It also saves the respondents a lot of typing (and potentially adding mistakes of their own or not getting the entire context).

Stuart

collab+-+13+01+21+programmatic+arrays+01.jpg

Prithivirajan Veerappan schrieb:

Please find the below example:

I need to evaluate Cm which is a 6*6 matrix..im not able to find the right syntax,could you please help.

Help to achieve what? Its not clear to me what your goal is. I was just guessing and came up with the attached,

See if it helps. It looks like that, apart from problems with syntax, you have a wrong logic in your assignment as you are assigning three diagonal elements a value which you overwrite with different values soon after. This because the first and the last of your three if conditions are identical. So in my proposal I omitted the first one completely, which probably is not what you want to achieve.

BTW, don't just type "if" in a program to get a conditional branch, you have to get that structure from the appropriate palette or use the keyboard shortcut.

Matrix2.png

Announcements

Top Tags