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

Shows variable is undefined

SOLVED

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.

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?

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

Re: Shows variable is undefined

Here is an approach which returns a nested vector

B.png

Worksheet in P4 format attached

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.

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

Re: Shows variable is undefined

Are these really the correct values you need?

B1.PNG

 

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

B2.PNG

 

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, ....

B3.PNG

 

Worksheet in format P5 attached

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.

Re: Shows variable is undefined


@fahmed-2 wrote:

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.


Not sure if I understand your problem.

You may use normal matrix indices to access single elements:

B.PNG

Highlighted

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.

B.PNG