Skip to main content
1-Visitor
March 23, 2015
Solved

Help with For loops

  • March 23, 2015
  • 3 replies
  • 3737 views


Can someone help me with this loop? I cannot seem to get the loop working for the for statement

Best answer by Fred_Kohlhepp

Mathcad index vectors starting from 0.

You wrote j := 1 to n, so Mathcad filled the zeroth slot with 0.

3 replies

19-Tanzanite
March 23, 2015

What exactly do you want the program to return? You pass i as a parameter to the program (i.e the program is a function definition), but i is defined as a loop variable, which overwrites any value of i passed as a parameter. In each if statement you have a local function definition (i.e. local to the program), and outside the loop you have two more local function definitions. A function definition does not create any numerical values though, it just defines the function. Do you want to return the values of alpha (case 1) or I (case 2) for all the values of i (this is what I suspect you want) or do you want to return one or more function names (which is possible, but since you have to ask this question, I suspect is not what you want).

rayakannu1-VisitorAuthor
1-Visitor
March 24, 2015

Richard, thanks for the response.

I am trying to evaluate the moment of inertia along the length of a column, which is divided into 8 elements. I have derived two expression for the diameter if:-

1. The first half of the column 0<x<l/2

2. The second half of the column l/2<x<l

I am trying the find the I value at each node, and then plot a graph along the length of the column for various values of alpha


23-Emerald I
March 24, 2015

See if this helps:

rayakannu1-VisitorAuthor
1-Visitor
March 24, 2015

Fred, that was excellent. Appreciate your help

5-Regular Member
March 24, 2015

Good day Ramani,

Looks like Fred Kohlhepp‌ has you up and running (thanks Fred); if so, would you please mark his answer as correct so we know you are all set?

Cheers,

Toby