Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

** Community Tip** - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements.
X

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Nov 03, 2021
05:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 03, 2021
05:48 PM

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!

Labels:

6 REPLIES 6

Nov 04, 2021
02:55 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 04, 2021
02:55 AM

Hi,

Can you please include the sheet with the posting.

Cheers

Terry

Nov 04, 2021
03:43 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 04, 2021
03:43 AM

Please attach your Mathcad worksheet to the message.

Nov 04, 2021
04:28 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 04, 2021
04:28 AM

Hi,

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

Cheers

Terry

Nov 04, 2021
07:04 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 04, 2021
07:04 AM

Hi,

Set up a solve block that will iterate to a solution automatically.

Nov 04, 2021
09:14 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 04, 2021
09:14 AM

@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

Nov 04, 2021
11:08 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 04, 2021
11:08 AM

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.