Get Help

Turn on suggestions

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

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Shows variable is undefined

Options

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

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

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-17-2019
10:00 PM

02-17-2019
10:00 PM

Re: Shows variable is undefined

Thank you very much for your reply. I am still learning Mathcad and trying to know the syntaxes to make my coding nice and efficient. I liked the first one that you have helped me out. This calculation set was done for one value of Z, is it possible to make it happen for a set of Z's and get segmentwise outputs for each Z. I can make it in a way which might be too long and not great.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-17-2019
10:56 PM

02-17-2019
10:56 PM

Re: Shows variable is undefined

You mean you have a vector of Z-values and each Z-value should calculate a 9 element vector?

What kind of data structure do you expect the result to be? A 9xn matrix or a nested vector?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-17-2019
11:05 PM

02-17-2019
11:05 PM

Re: Shows variable is undefined

I mean I have a vector of Z-values and each Z-value should calculate an m element vector? Here, m is the number of rows/values in the "I" vector. I need to have an nxm matrix where each column represents one depth

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-17-2019
11:06 PM

02-17-2019
11:06 PM

Re: Shows variable is undefined

Here is an approach which returns a nested vector

Worksheet in P4 format attached

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-17-2019
11:23 PM

02-17-2019
11:23 PM

Re: Shows variable is undefined

The (kai subscript "0") should not be constant. It will change the way as you have shown me in the if else loop. I am trying to do this whole calculation set for an n element "Z" vector where the "I" is also an m-element vector.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-17-2019
11:37 PM

02-17-2019
11:37 PM

Re: Shows variable is undefined

I can do the whole in only one column vector but I am trying to implement it in different columns where each column represents one depth. I have attached my work

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-18-2019
06:35 AM

02-18-2019
06:35 AM

Re: Shows variable is undefined

Are these really the correct values you need?

If yes, then the calculation can be simplified and corrected so the result is a true vector:

Now we can go ahead and create a function which returns a matrix - one column for every value of Z. Again, Z.new should be a vector, not a range. That way the result is a true vector/matrix and we can use it to build a table, export the values, ....

Worksheet in format P5 attached

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-18-2019
07:48 AM

02-18-2019
07:48 AM

Re: Shows variable is undefined

Thank you very much again Werner_E. This works like a magic. I am really thankful. In the final stack, how can I get a value for a particular column and row. For example, if I need to find the value at 3m depth for rainfall of 0.5 mm/hr. I can do for a single column or, a single row but not at a particular element.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-18-2019
08:10 AM

02-18-2019
08:10 AM

Re: Shows variable is undefined

@fahmed-2 wrote:

Not sure if I understand your problem.

You may use normal matrix indices to access single elements:

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-18-2019
09:22 AM

02-18-2019
09:22 AM

Re: Shows variable is undefined

You can even use the table T I created to define an interpolation function so you can evaluate it at arbitrary values for I and Z or plot the 2D-surface.

The routine in the attach uses simple linear interpolation but you may use spline interpolation as well.

Top Tags