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

## Mathcad 15 Getting Vectors From For Loops  1-Newbie

## Mathcad 15 Getting Vectors From For Loops

So I have a hw problem that doesn't need to be solved this way but I have a feeling I will be using the Modified bishops method on a future project so I wanna take my time on this. Basically, I have two equations : This is a function to find the Factor of Safety for a slope under certain conditions. In the actual psi equation, the F is The same FS in the upper eq. This requires an iterative process where you guess a F run it through psi and then the FS function. You then compare F to the resulting FS to see how close they are. You continue guessing F until F and FS converge to a similar number. The summations with the variable I represent the 7 different vertical slices that are being summed to form the whole slope. I want to write a program where I can input F as a sequence like 1,2 .. n. It then should pick the first F and run it through psi summing over the 7 slices. This should output one character into the psi resultant vector. Overall once it has run through all F, I want the resultant psi to be an nx1 vector with each psi value pertaining to each F. Then I want it to run the FS equation, similar to the psi I want this to sum over the seven slices for each psi input. At the end, I should have a resulting FS vector with one FS value for each F value input. Here is what I have so far: I am an absolute beginner with coding so any help would be greatly appreciated!

6 REPLIES 6  20-Turquoise
(To:AS_10102578)

Hi,

Can you please include the sheet with the posting.

Cheers

Terry  24-Ruby I
(To:AS_10102578)  20-Turquoise

Hi,

We need to know the values of "l", "c", "w", "u", phi, and alpha to help you.

Cheers

Terry  20-Turquoise
(To:AS_10102578)

Hi,

Set up a solve block that will iterate to a solution automatically.   23-Emerald II
(To:AS_10102578)

@AS_10102578 wrote:

So I have a hw problem that doesn't need to be solved this way but I have a feeling I will be using the Modified bishops method on a future project so I wanna take my time on this. Basically, I have two equations : T At the end, I should have a resulting FS vector with one FS value for each F value input. Here is what I have so far: I don't have your version of Mathcad (I've only got Prime Express 7). However, I can make a few comments on the code you've shown.

You are expecting ψF to be a vector and use it as such in the 2nd expression for FS.  However, ψF doesn't exist as far as FS is concerned.  ψF is a local variable within the first FS expression and doesn't exist outside of it. So what you needed to have done was assign the result to variable ψF instead of FS - this ψF is a different object to the ψF defined within the first expression.

A second problem you've got is that the ψF in the 1st expression is *not* a vector.  All the expression is doing is assigning the summation result to ψF., overwriting any previous values.  Consequently, the first FS simply has the value of ψF for F = 6.  You need a second iterator to assign the results to a new element in ψF  (you could use F, but only if any future F you have in mind continues to pull its values from an integer range).

The third problem is that you need an iterator (range variable or for/while loop) in the second expression to select each value of ψF; otherwise, you're just dividing the (intended) vector ψF into the top summation expression.

Unfortunately, my version of Mathcad doesn't allow programming, but I can show a (crude) version of your code that uses functions. Often, but not always, you can use vectorize operator to carry out parallel operations without using an iterator.  Occasionally, you can write an expression so that Mathcad automatically iterates over an expression. Stuart  23-Emerald II
(To:AS_10102578)

Apart from your iteration proposal and the solve block proposed elsewhere you can also do: If you equate this to FS, you get: So eventually: If you define: You can solve that simply with the Mathcad's built-in root() function: But of course only if the vectors l, u, w alpha, and the values phi and c are known.

Success!

Luc

P.S. Of course you could also define the function f as: but this function has a higher risk of running into errors because FS is the denominator of a ratio that fails if FS becomes 0. 