Skip to main content
8-Gravel
February 14, 2023
Question

Extract nearest values from matrices. Substitute first value in one of the double summation series.

  • February 14, 2023
  • 1 reply
  • 1960 views

1. For each element of matrix "Em", it is required to match only one closest value from matrix "E_exp_int".
Corresponding to that matched element of "E_exp_int" it is required to lookup flow and obstruction values in "flow_int" and "obstruction_int" matrices.
The looked up elements of flow_int and obstruction_int will be used for calculating variable "status", as shown below. Right now, there are just flow and obstruction matrices only.


2. The summation corresponding to index m starts from 0. For m=0, a constant "lateral_coeff" will be used in place of variable "status". Then, first term of summation needs to be given half weight.

 

 

1 reply

25-Diamond I
February 14, 2023

The


@ajay94_shan wrote:

1. For each element of matrix "Em", it is required to match only one closest value from matrix "E_exp_int".

The name of that vector is not E.m but rather simply E.

And E contains 300 values in the range from 1.01 to 304, while E_exp_int contains 100000 values in the range from 0.008  to 4.1.
Are you really sure that you want to look for near values? All values but the first four in E are larger than the largest value in E_exp_int, so theis value (4.138) would be the "nearest" value for them.

Werner_E_0-1676385036363.png

Here is a function to get the nearest value to a value x in a  vector v

Werner_E_1-1676385745058.png

 

 

As for the second problem - you set ORIGIN to be 1 at the top of the sheet, so obviously a index 0 is an invalid matrix index.

 

25-Diamond I
February 14, 2023

Here is a version of "getNearest" which I would trust more as it does not use "match".

Werner_E_0-1676386878971.png

 

8-Gravel
February 15, 2023

Thanks Werner_E for your effort. I understand your point on setting ORIGIN:=1 and m=1 in the beginning itself, and also about the comparision of E and E_exp_int.

 

Before posting here, I was aware of the fact that if for m=0, the worksheet does not evaluate completely and also about the fact that  a few values are there in E whose magnitude is close to the several values in E_exp_int. But, I may have some "f" results which in turn can make  E_exp_int featuring several nearby but different values and some exactly same values. At present, I see that we are getting several nearest values just because interpolation is too fine. But it is certainly not desirable to print several duplicate values (as mentioned in my original post we need only one nearest value), e.g, 4.138 occurs several times in Near2. Further, I need help in printing corresponding matrices of "flow_int" and "obstruction_int" . Please help.

 

I tried several possibilities of using "if", "for" etc. for defining first term in summation for m=0 but I failed. Further, I shall say that the first term in summation shall be divided by 2 after using lateral_coeff.

 

Thank you once again!