Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
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.
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.
Here is a function to get the nearest value to a value x in a vector v
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.
Here is a version of "getNearest" which I would trust more as it does not use "match".
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!
Actually I must confess that I am lost because I don't understand what you really are after.
My functions getNearest(2) look for the nearest value of a given scalar value x in a given vector v. And When we call this function for every value in E, you sure get one value for every value in E and so the result is a vector with as many elements as in E.
Thats how I understood your initial question but if thats not what you are looking for, you would have to be more concise in describing what you are looking for. Of course it would be possible to write a utility function which removes duplicate values in a vector if thats it what you need.