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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Help with For loops

rayakannu
1-Newbie

Help with For loops


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

1 ACCEPTED SOLUTION

Accepted Solutions

Mathcad index vectors starting from 0.

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

View solution in original post

12 REPLIES 12
RichardJ
19-Tanzanite
(To:rayakannu)

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).

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


See if this helps:

Fred, that was excellent. Appreciate your help


Fred, I have modified my original program in the attached file. Can you please advise me why it is not working?

Your program block is still only returning the last calculation thru the for loop.

Fred, can you please help me to correct the program I wrote so that know what you were saying?

Thanks

Open the file I attached (Untitled A_2) and read the notes.

Fred, did you notice that for j=1, the result is 0? this should not be the case.

Mathcad index vectors starting from 0.

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

Ok, thanks you very much

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

Top Tags