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

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

Mar 14, 2022
12:51 PM

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

Mar 14, 2022
12:51 PM

If Statements Within Tables

Hi guys i have a tabulated problem of which I am trying to multiply out various terms

There is a column headed mp. as each term is multiplied out there becomes a point where this figure becomes a minus value. At this point i need the equation to change. I have tried an IF statement however because i am working within a table format it will not let me achieve this function.

I was wondering has anyone come across this or should i remove the table element and do this long hand?

Sheet attached

Thanks 🙂

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Mar 15, 2022
09:47 AM

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

Mar 15, 2022
09:47 AM

The main reason you are getting the error is because Prime does not allow to vectorize a comparison operator directly. A workaround is to define a function beforehand which does the comparison and call that function vectorized.

So the vector mp is now calculated as you expected it and could be used afterwards. But the use of a Prime table for doing so is not needed (and does not make much sense IMHO) anyway.

As Fred already wrote a Prime table can only be used to input data vectors manually but is in no way helpful if your goal is to display data.

Prime does not offer a decent way to display data in a nice and clear way. You may create a table by augmenting the data vectors

Or you can get rid of the units in the table and add an (ugly looking) header

11 REPLIES 11

Mar 14, 2022
02:03 PM

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

Mar 14, 2022
02:03 PM

Two quick observations:

1) Mathcad is not EXCEL. Tables in Prime are only data entry vehicles. If you copy a range of numbers from an EXCEL spreadsheet and simply paste them into Mathcad, (cntrl-P) you'll create a table--the numbers will appear with two blank place holders at the top of each column. The top placeholder is for a variable name, the one below is for a unit if one is needed. **These are now vector variables in Mathcad.**

2) Unlike EXCEL you can't put formulas into a table. They are for **input only.**

But, once you have the variables you can write functions to operate on them or simply define new variables from combinations.

One more observation: there are two types of subscript--literal and index. A literal subscript (ctrl-0) is part of the variable (All of your subscripts appear to be literal.) An index subscript ([) points to one element of a vector variable.

Index subscripts must be integer numbers, but they can be computed numbers.

Proper use of Mathcad can make this much easier to understand.

Mar 15, 2022
07:07 AM

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

Mar 15, 2022
07:07 AM

Thanks Fred, understand where you are coming from.

The table idea would work if there wasn't an IF statement i.e. if i wanted the total value of mm I could use sum of get the answer. I was trying to find a way to present data and formulas in one place which would in excel be a traditional iterative process.

To quote Luc there is no easy way to learn Mathcad, you learn it from using it.

I was just trying to come up with something different

Thank you for your input.

Mar 15, 2022
09:47 AM

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

Mar 15, 2022
09:47 AM

The main reason you are getting the error is because Prime does not allow to vectorize a comparison operator directly. A workaround is to define a function beforehand which does the comparison and call that function vectorized.

So the vector mp is now calculated as you expected it and could be used afterwards. But the use of a Prime table for doing so is not needed (and does not make much sense IMHO) anyway.

As Fred already wrote a Prime table can only be used to input data vectors manually but is in no way helpful if your goal is to display data.

Prime does not offer a decent way to display data in a nice and clear way. You may create a table by augmenting the data vectors

Or you can get rid of the units in the table and add an (ugly looking) header

Mar 15, 2022
12:07 PM

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

Mar 15, 2022
12:07 PM

Thanks Werner_E

Mar 15, 2022
12:49 PM

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

Mar 15, 2022
12:49 PM

Some additional remarks:

The only reason for using the table is the vector T.s.

You could create it much simpler by using

and can then create other vectors depending on it without using a table:

The vectors c, k.c, c'k.c, k.q and rho0 could be created more comfortable of you define the appropriate values as vector elements right from the beginning.

E.g. Instead of defining c.u0:=.... in your collapsed region you could write c[0:=..... where "[" denotes making a matrix index.

That way you can omit the whole table and may create a (less nice looking) table as shown to display the results.

Mar 15, 2022
01:00 PM

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

Mar 15, 2022
01:00 PM

Thanks Werner

Agreed the Tp is the only reason why i have presented it that way. i will play around and see what i can come up with.

Ultimately i want to get mp to as close to zero as possible, of which would therefore iterate the depth df.

as you can see the attached sheet shows mp @ -82.667kNm when df is = -3.4m

is there an iteration function you could recommend to over come this and save the manual changing of df.

Thanks : )

Mar 15, 2022
01:26 PM

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

Mar 15, 2022
01:26 PM

I am not yet sure how your calculation of mp depends on df exactly, but I found a lot of things you could streamline and simplify if you use vectors rigth from the start and not a myriad of variables with a literal index.

For example the 35 values "z.b" can be done in one go like this

Then all 35 values for phi could be calculated as vector like this:

I renamed the four element vector phi you created in the table to phi.table to be able to use the name phi for the 35 element vector created.

Then k.c, etc. etc.

Again note the the subscript "c" of "k" is a literal index (part of the name, nothing you can calculate with) while "idx" is a matrix/vector index.

Mar 15, 2022
01:36 PM

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

Mar 15, 2022
01:36 PM

Thanks Werner

So the value of df effects mp because its essentially an initial guess to where the fixity lies at depth df.

so changing df gets mp closer or further way from mp. the closer to zero the better.

You can see below at the point where the value starts to become a minus kNm answer.

the sum of these answers is dependent on df and changing that will get me closer to zero etc

Mar 15, 2022
01:56 PM

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

Mar 15, 2022
01:56 PM

Still see no iteration, still confused by your many singly created variables. Or are those 35 values just there to find the most appropriate of them? But then most don't depend on d.f ??

BTW, the calculation of rho

Wouldn't

simplify to just

? So We could then, using vector indexed variables, do

Furthermore I wonder if z.b really is meant to be dimensionless. After all all you add the unit meter at all of your subsequent calculations. It would be more convenient if you add that unit right from start. maybe "b" should be dimensionless??

Mar 15, 2022
02:22 PM

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

Mar 15, 2022
02:22 PM

Addition:

Here is a way to define m.p without using a comparison (and so without the need of an auxiliary function) using the "sign" function.

Only difference to your original function is when A.z is zero. This new function now returns 0 in that case.

And if your goal is to find the value of d.f where the sum of m.p yields zero, you have to turn the calculation of those sum into a function of d.f and then either use a solve block or the root function like this:

See if the attached file is of help.

Mar 16, 2022
06:42 AM

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

Mar 16, 2022
06:42 AM

Hi Werner,

Yes there was an error with the first z.b, they should both match. Thank you for this i have picked up and amended

The first z.b. was non-dimensionless because it was reading the corresponding kp and kc values from the interp function.

I can see that the idx function removes all need for a tabulated approach. first time I have seen this but its a great idea, thanks i will incorporate into my other sheets.

The original value of 34 was because the maximum possible number required would be up to 8.5m which is divided by the incremental value of 0.250m

Thanks : )