Skip to main content
10-Marble
October 19, 2025
Solved

Not getting the results as J <---- J+1 not doing well

  • October 19, 2025
  • 3 replies
  • 2704 views

I am working on a sample to develop my calculations.

I used both If .. Then and While.

But, I can get the results: J is not adding up. Looks like J keeps remaining at 1.

 

I request help.

 

Best answer by Werner_E

Your programs don't show what you intend to do if the function argument x is not exactly in the list of nominal diameters.
The programs (with Terry's fix applied) will return just the last value of j in this case (15).
If, as I assume, that's not intended, you could simply place the return value you want to see in case of an invalid x in the last program line, like:

Werner_E_5-1760878693857.png

 

To achieve what you obviously intend to do (take the nominal diameter ND, lookup the corresponding outer diameter OD and use it to calculate the cross-sectional area) could more easily be done using the "lookup" function:

Werner_E_0-1760877012952.png

To avoid the error in case x is not in the list you could add your own return value in case lookup fails:

Werner_E_1-1760877084765.png

I think that returning the index j as well was done just for debugging. But in case you really need that index you could use the "match" function (see attached sheet).

You may also just use the next larger value in ND in case x is not found in that list

Werner_E_2-1760877281033.png

Similarly you could also decide to use the next smaller value or the nearest value (see attached sheet).

And of course a further option would be to use linear interpolation to deal with x-values not in the ND-list.

Werner_E_6-1760878723404.png

Prime 11 file attached

3 replies

21-Topaz II
October 19, 2025

Hi,

The comparison equals is a bold equals sign and is entered by the following keys together [CTRL][equal  sign].

Capture.JPG

Cheers

Terry

Werner_E25-Diamond IAnswer
25-Diamond I
October 19, 2025

Your programs don't show what you intend to do if the function argument x is not exactly in the list of nominal diameters.
The programs (with Terry's fix applied) will return just the last value of j in this case (15).
If, as I assume, that's not intended, you could simply place the return value you want to see in case of an invalid x in the last program line, like:

Werner_E_5-1760878693857.png

 

To achieve what you obviously intend to do (take the nominal diameter ND, lookup the corresponding outer diameter OD and use it to calculate the cross-sectional area) could more easily be done using the "lookup" function:

Werner_E_0-1760877012952.png

To avoid the error in case x is not in the list you could add your own return value in case lookup fails:

Werner_E_1-1760877084765.png

I think that returning the index j as well was done just for debugging. But in case you really need that index you could use the "match" function (see attached sheet).

You may also just use the next larger value in ND in case x is not found in that list

Werner_E_2-1760877281033.png

Similarly you could also decide to use the next smaller value or the nearest value (see attached sheet).

And of course a further option would be to use linear interpolation to deal with x-values not in the ND-list.

Werner_E_6-1760878723404.png

Prime 11 file attached

RWickrama10-MarbleAuthor
10-Marble
October 19, 2025

Thank you for the great reply.

I explored all the options.

I did well. BUt I get some issues.

When my input is not a listed data, I don't get the message.

I appreciate if you can shed some light on this issue.

Please see the attched Mathcad  file.

Thanks again

 

 

23-Emerald V
October 21, 2025

Thank you, but, no, just the one cup.  It required less tidying up than I thought,

 

Although I did accidentally delete some work I'd done on the reverse transformation str2unit.

 

I'm half sure I did something similar a long time ago, but I couldn't find the worksheet, so I thought it was quicker to recreate it from scratch.   I've added a few more derived units to the worksheet and created a very inelegant str2unit

 

I might brood on str2unit for a little bit longer, as there is at least one bug in it that I need to fix, and a few more derived units to add.  Or, apart from the bug fix, I might not, as I have a shedload of other worksheets that I'm working on Expressifying.

 

You might notice one significant omission from the vector of frequencies, and therein lies my bug.

 

2025 10 21 E.png

 

Stuart 

RWickrama10-MarbleAuthor
10-Marble
October 25, 2025

I got to work on my calculations comfortably. I thank everyone for the help.

Attached here to is one of my final calculation, but WIP: I need to add some images from a Revit model.