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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Table of results

JohnWoodgate
6-Contributor

Table of results

I have a fairly complex formula for I(q,x) and I want to tabulate the results with q values (1 - 5) as the columns and x values (1 to 5) as the rows. I've no doubt it's very easy, but I can't see how to do it.

I apologize if I've posted this question to the wrong forum.

1 ACCEPTED SOLUTION

Accepted Solutions

JOHN WOODGATE wrote:

Well. I copied your script into mine, with strange results. The graphs are correct, I belive (I can check with the inverted equation, which should always give H = 0.4). But the tabled values are mostly not correct, and those that are, may be coincidence. Anyway, I've attached my worksheet for your appraisal.

The reason is that you have to switch the arguments of I(), either when you define I() or when you call it.

In your very first post you said you had a function I(q,x) and want a table with x (which is the second argument of the function) as rows. So my solutions took this for granted.

In your sheet you have defined I(x,gamma) and obviously you want a table with x (which is now the first argument of the function) as rows. So of course you have to switch the order of the arguments to get it right.

If you would use my last approach, you wouldn't need the auxiliary function for the very same reason either.

1.png

View solution in original post

14 REPLIES 14
MikeArmstrong
5-Regular Member
(To:JohnWoodgate)

There is probably a number of different ways to achieve this.

Could you post an example?

Thanks for prompt response. Here is the output table from Excel. I have to show that Mathcad gives the same numbers. x in my original message is B in the Excel sheet.

q12345
B




0.59.546.165.495.385.41
0.755.354.094.024.104.18
13.953.443.533.643.71
1.253.373.233.373.483.54
1.53.123.193.363.463.52
1.753.043.253.443.543.60
23.053.373.573.673.73
2.253.113.533.743.843.90
2.53.213.713.944.044.09
2.753.333.914.154.264.31
33.484.124.374.494.54
3.253.634.344.614.734.79
3.53.804.574.864.985.04
3.753.974.815.115.245.30
44.155.065.375.505.56
4.254.345.305.635.775.83
4.54.535.565.906.046.11
4.754.725.816.176.326.39
54.926.076.446.596.67
MikeArmstrong
5-Regular Member
(To:JohnWoodgate)

Based on the information provided Werners example should do the trick.

Live data is much more productive to work BTW.

Mike Armstrong wrote:

Based on the information provided Werners example should do the trick.

I would be a bit more tricky concerning the indices as the stepwidth of x (B) is not 1. But of course it could be done (see below). We may even add row and column headers, as long as we are working without units.

Nevertheless I would suggest to provide the values of x and q as vectors and invest in a utility routine which creates the table. This routine would have four arguments: the function name, vector of row values, vector of column values and a flag indicating if row/columns headers should be created.

1.png

Thank you. I don't understand your reference to 'live data'. Do you mean that I shoudl have uploaded my Mathcad worksheet?

JOHN WOODGATE wrote:

Thank you. I don't understand your reference to 'live data'. Do you mean that I shoudl have uploaded my Mathcad worksheet?

Exactly that! Either your original sheet, or, if it contains confidential data or is simply so large and confusing a simple trimmed down dummy sheet.

We ike to have something to play with and it usually makes more clear what exactly you are after.

JOHN WOODGATE wrote:

I have a fairly complex formula for I(q,x) and I want to tabulate the results with q values (1 - 5) as the columns and x values (1 to 5) as the rows. I've no doubt it's very easy, but I can't see how to do it.

Maybe something like the two approaches attached?

If the values for x and/or q are not in ascending order with step size 1, different approaches are necessary. If thats an issue, ask again. Also, if you would like to have rudimentary row and column headers.

1.png

JohnWoodgate
6-Contributor
(To:Werner_E)

Thank you very much. These are simple enough even for little me to understand. I probably only need to do this once, so no refinement is really necessary.

As explained above here is a more general approach by defining a utility routine and providing the row and column values as vectors. The function is assumed to have two independend arguments and the table created would have the first argmuent for the rows and the second for the columns. As your function seems to be defined the other way round, you will have to create am auxiliary function.

1.png

I am not including the worksheet as we still don't know which version of the program you are actually using.

JohnWoodgate
6-Contributor
(To:Werner_E)

This, too, is not too difficult for me, but maybe more than I require. I'm using Mathcad 15 at present. Thank you very much.

How can I retrieve your worksheet/ I can screen-grab, of course, but I wonder f there is a better way.

JOHN WOODGATE wrote:

This, too, is not too difficult for me, but maybe more than I require. I'm using Mathcad 15 at present. Thank you very much.

How can I retrieve your worksheet/ I can screen-grab, of course, but I wonder f there is a better way.

Retrieving the sheet is easy - you simply ask for it.

Here you are!

JohnWoodgate
6-Contributor
(To:Werner_E)

Well. I copied your script into mine, with strange results. The graphs are correct, I belive (I can check with the inverted equation, which should always give H = 0.4). But the tabled values are mostly not correct, and those that are, may be coincidence. Anyway, I've attached my worksheet for your appraisal.

JOHN WOODGATE wrote:

Well. I copied your script into mine, with strange results. The graphs are correct, I belive (I can check with the inverted equation, which should always give H = 0.4). But the tabled values are mostly not correct, and those that are, may be coincidence. Anyway, I've attached my worksheet for your appraisal.

The reason is that you have to switch the arguments of I(), either when you define I() or when you call it.

In your very first post you said you had a function I(q,x) and want a table with x (which is the second argument of the function) as rows. So my solutions took this for granted.

In your sheet you have defined I(x,gamma) and obviously you want a table with x (which is now the first argument of the function) as rows. So of course you have to switch the order of the arguments to get it right.

If you would use my last approach, you wouldn't need the auxiliary function for the very same reason either.

1.png

JohnWoodgate
6-Contributor
(To:Werner_E)

I apologize for the confusion. The function is defined in the two different ways in my files on the subject. Thank you very much for your patience.

Top Tags