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

8-Gravel

## I need help in Looping or any other technique in four equations

Hi,

I am still learning Mathcad. I need help with making some of the formulas easier, with looping or any other technique.

My spreadsheet is full of some equations with toms of variables, each one is calculated previously 12 times,

I appreciate it if someone can provide a shorter format for each of the following four equations, and I will try to apply the same technique in all of them...

Thanks a lot

13 REPLIES 13
23-Emerald II
(To:Eng_ReyD_497)

Make sure W and Ws are vectors, then you can use summation:

And be sure to attach your worksheet for further help, not just a picture.

Success!
Luc

8-Gravel
(To:LucMeekes)

Thanks  @LucMeekes

I do not think that this is what I need.I apologize if I was not clear enough.

I already have W1, W2, W3, .... etc defined before. Similarly for all the variables on the right-hand side such as M1sm2, M1sm3, etc,

I want to rewrite the four equations: WcswWssw, Mrmw, and WTw  in a shorter form instead of repeating all the variables, getting an advantage of the looping technique...Thanks again

20-Turquoise
(To:Eng_ReyD_497)

Hi,

Example you use M[1 to define the variables.  They then make a vector that can be summed.

23-Emerald II
(To:Eng_ReyD_497)

From your picture (It's really more helpful if you attach your Prime worksheet!) I see you have your variables named all independently, using literal subscripts. With that approach there is no way you can use loops or whatever to simply the operations you want to do.

So, You need to define your variables in the form of vectors, matrices or the like. Those you can index and that allows looping.

Success!
Luc

20-Turquoise
(To:Eng_ReyD_497)

Hi,

Please enclose your worksheet and we can show you how to use indexing.

Cheers

Terry

Thanks LucMeekes and terryhendicott for the help...

As requested, I am attaching a simplified sample of the worksheet containing the bone of the calculations Please note that many variables are currently in a hidden range that you can expand. The actual sheet is over 40 pages for repetitions!, but if I learn how to do it I think I would be able to apply everywhere...

I will experiment with some techniques as I learned above, but I appreciate if someone can provide some insight considering the bigger picture as I enclosed here..
@LucMeekes
@terryhendicott

23-Emerald II
(To:Eng_ReyD_497)

Here's the proposed approach:

See attached Prime6 file.

With this you don't need the variable NM anymore, and also the first row of your Module matrix is obsolete, or you can change it to titles:

If you want to calculate more than 3 items, just add them to Mod. You don't need to change the other formulae, the definition of m takes care of the number of items. Example:

Next thing is, you need to make sure that all your calculation can deal with the vectors.

Hmm. I see that your further formulae use ORIGIN=0 (the default) . Maybe better keep ORIGIN=0.

Just delete the 'ORIGIN :=1' definition and all is well.

Success!
Luc

20-Turquoise
(To:Eng_ReyD_497)

Hi,

Have taken some time with your worksheet.

I have created the values as vectors and used two ranges "i" 1 to 12 and "j" 2 to 12 to do this.

You reference a value in a vector (or matrix) using the square bracket for instance V[3 gets you a value from the V.

By default the indices start at zero and you can change that.  At the top of the sheet I reset ORIGIN = 1 to set the first element to be position 1 for better understanding of the formulas.

I have left some subscripted expressions for you to change they are highlighted in red and are easy to change.

I have left them so you can see the very subtle difference between a subscripted variable and an indexed variable.  The index is a little lower compared to the subscript.

Hope this all helps.

Enclosed worksheet

Cheers

Terry

20-Turquoise
(To:terryhendicott)

Hi,

spotted a small error. Corrected in Version 2.

Thanks @terryhendicott  & @LucMeekes for your help
I am experimenting with your solutions and still learning...
I am not sure why the attached does not read the variables, although I think I have followed the steps?
Thanks again!

23-Emerald II
(To:Eng_ReyD_497)

See attached sheet for comments and suggestions.

Success!
Luc

8-Gravel
(To:LucMeekes)

@LucMeekes
Thanks a lot for the great info. I added some comments/ responses to your comments in "red" in the attached.
I am getting there!! Thanks again for this great learning experience

23-Emerald II
(To:Eng_ReyD_497)

Added a few remarks...

Success!
Luc

Announcements