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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Data syncronize by using component (mathcad 15)

SKim
1-Newbie

Data syncronize by using component (mathcad 15)

Hello there,

Above all, I am the very biginner for Mathcad as well as programming. So please forgive me if my questions would be so basic or stupid. (i am trying. ;;;)

Since I have several data to be selected by users, I've decided to use mathcad 15 than prime so that I can make full use of components.

I am making a calculation worksheet with a number of back data and I want to know how to syncronize data, like. (refer to the attached also)

example.jpg

I have 4 materials for moment having information of size 1&2, parameter 1&2.

Some information is duplicated, some is not.

Under this situation, I want to program like..

when I select material 1 in the 1st list box (or ribbon which is more favorable), the second list box (or so) shows only the applicable information.

the third, forth and fifth.. accordingly.

Any advice on this?

By the way, I read a forum explaining about list box which was greatly helpful to me and I could hardly understand a part.

I've brought a screen shot below and I want to know what "+3" or "+1" of steel +3, property+1 does exactly mean or work.

mathcad.png

Thanks so much in advance.

S

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:SKim)

I guess the attached sheet should do what you want.

EDIT: Changed the components script slightly so the type of the return value is identical to the input type and not automatically converted to a string. So the subsequent str2num() conversion can be omitted.

View solution in original post

31 REPLIES 31
AndyWesterman
4-Participant
(To:SKim)

Hi,

Its not so easy trying to explain without the original mathcad file, but here goes.

Some where in the sheet you have a two dimensional array 'data' defined which contains all the information that you want to access.

Next you have 2 list boxes which allow you to select from a number of items and each will return a number which identifies the choice that you make.

so in the picture that you show ,

for 'steel' perhaps:

diameter 12; steel = 0

diameter 16; steel = 1

diameter 20; steel = 2

diameter 25; steel = 3

and similarly for the value 'property'.

these values can be used to find a unique entry in the data array,

In the attached file you will see how the index system works, the first number specifies the row & the second the column.

Sometimes it is helpful to put a text row or column (or both) to describe what the data means & if necessary units for the data.

So the first few rows & columns may not contain numbers.

by using 'steel + 3' a value of 0 for steel will get the data from row 3.

Hope this goes some way towards an explanation of what you sheet is doing.

Regards

Andy

Thanks so much for your attention and suggestion.

I got the sense of matrix index number thanks to you.

BTW, I am not still pretty sure how to use (or start) list box for those data - maybe as you said, it's not easy to explain with example sheet.

what I want to do is like PIVOT in excel - Only possible to show (or be able to select) applicable data according to the condition.

1. If you choose material M,

2. Only following size(sizes) is shown

3. Then, surely only following value is shown. (Size A would have values 130 and 500, while Size B would have ones 130 and 400)

example-pivot.png

Thanks for the attention again.

Best regards,

S

AndyWesterman
4-Participant
(To:SKim)

the attached shows a few ideas (mainly take from this , or the previous forum).

Hopefully it will give you a starting point for creating the listbox structures that you want.

the first (Steel) it a fixed list which will always look the same, the second one (Property) takes Steel as a parameter & is written to show specific values for each version of Steel.

The last list box is added as an example of how the list box can be given a set of strings through an input parameter.

I've tried to minimise the amount of code in each box , but if you have any questions, feel free to ask.

Regards

Andy

Werner_E
24-Ruby V
(To:SKim)

I guess the attached sheet should do what you want.

EDIT: Changed the components script slightly so the type of the return value is identical to the input type and not automatically converted to a string. So the subsequent str2num() conversion can be omitted.

SKim
1-Newbie
(To:Werner_E)

Hello Werner,

I am trying with your helpful example and here, quick question.

Is there any limitation to have list boxes?

I was on making list boxes which are more than a dozen and faced definition error.

The error mark was on the term "Filter" in Filter(Data,stapeln(,,,,))

So.. any limitation?

Thank you so much.

S

Werner_E
24-Ruby V
(To:SKim)

S Kim wrote:

Hello Werner,

I am trying with your helpful example and here, quick question.

Is there any limitation to have list boxes?

I was on making list boxes which are more than a dozen and faced definition error.

The error mark was on the term "Filter" in Filter(Data,stapeln(,,,,))

So.. any limitation?

Thank you so much.

S

There is no limitation for the number of listboxes that I would be aware of.

Maybe its a wrong usage of my routine Filter.

Filter ist a function with two arguments, tbl ist data table without row or column headers and flt ist a vector with data values used to filter the table.

Filter takes the value of the first element of flt and deletes all rows in the table which do not contain that value in the first column. Then it takes the second value in flt and additionally(!) deletes all rows which do not contain that value in the second column, and so on. When its through with that procedure it will return the next column of the table.

So when we go the listboxes from left to right in the example sheet, the result of the last listbox is added to filter argument using stack(stapeln in your German version), so only values are presented which correspond to the values selected before.

The routine was a quick hack without any error handling. So you have to ensure that the values provided in flt really exist in the appropriate column of the data table and that there is a "next" column which can be returned.

The listbox itself and the script used within is fairly basic and more or less copied from Richard's fine selection of components. Its the Filter routine which ensures that only the appropriate values are shown. I don't feel that comfortable with scripting components but I guess that the filtering may be done even more efficiently inside the component itself by appropriate scripting.

BTW, What was the error message you got?

SKim
1-Newbie
(To:Werner_E)

Filter got "RED" marked and mssage said the value(!!) is not defined.

Because server has a problem here, I have yet to access MC. Will try more and keep you updated sooner.

Thanks always,

S

Werner_E
24-Ruby V
(To:SKim)

S Kim wrote:

Filter got "RED" marked and mssage said the value(!!) is not defined.

Because server has a problem here, I have yet to access MC. Will try more and keep you updated sooner.

Thanks always,

S

You may then use "trace error" (right click on error) to get further information.

If you created a new sheet - you sure have copied the area with the utility routines, where Filter is dedfined, to that sheet.

SKim
1-Newbie
(To:Werner_E)

BTW,

How can i have this (list box - data sync) in Prime 3.0 - at least similar? (i've learned list box with other control function is not supported in MP 3.0.)

S

I am still waiting for PC guy to solve this. on_

Werner_E
24-Ruby V
(To:SKim)

S Kim wrote:

BTW,

How can i have this (list box - data sync) in Prime 3.0 - at least similar? (i've learned list box with other control function is not supported in MP 3.0.)

S

I am still waiting for PC guy to solve this. on_

For heaven's sake! Why would you like to use Prime!??

You could use my Filter routine to show a vector consisting only of the values the user should chose from and the user then will have to assign a specific variable the index of the entry he choses. Using this index you can add the entry to flt and again use Filter to create the next list of choices. Awkward, but possible.

Have you already solved your problem with the many list boxes?

SKim
1-Newbie
(To:Werner_E)

hahaha,

I am still working on Mathcad 15 and it seems working thanks to your help.

But the limitation error(?) about which I questioned yesterday, I had yet no chance to solve it. I believe I could do that.

I don't know why my boss is addicted to Prime version all of a sudden even though I've explained and shown this forum to him in order to persuade 15 is a lot better.. and his answer is... Prime is becoming "TREND". on_

and he is not so happy that I am struggling with 15 while I insist to use that.

(told him that I do hardly handle 15, how can I work with prime? - his answer.... then forget about 15, study prime. LoL)

Only for the sake of proving that 15 is better for this!, I wanted to know how it works with Prime.

again, thanks Werner.

S

Werner_E
24-Ruby V
(To:SKim)

The problem is that your boss is right (from his point of view).

For someone new to Mathcad or Prime, the question seems not to be MC15 or Prime but the question is Prime or some other software.

Sure, Mathcad 15 is a lot better than Prime, to say the least, has the better workflow and much more powerful features. But MC15 is outdated and I don't think PTC will invest ressources to make it Win8.1 ready (MC15 will run fine under W8.1, but for some hardware configurations there are some problems with 3D plots). We can't be sure at all if MC15 will run fine under future versions of Windows. So I guess that at present time a company can't afford to implement an outdated software like MC15 as a company standard. The decision is to either look for some other software or to struggle with Prime3 now and hoping that Prime 6 or Prime 10 will be up to the needed standards. Its my feeling that a company can't afford the latter option, too.

For areas where Mathcad is already established the very same question will have to been answered sooner or later, too, of course.

SKim
1-Newbie
(To:Werner_E)

Good morning Werner,

Routine filters are working now. - think it was location issue.

I hope that I could show you the complete file soonest.

Wich you a great day.

S

SKim
1-Newbie
(To:Werner_E)

Me, again.

What can I do to apply for LOOKUP function in MC 15?

I have 2 data files in excel.

File A includes: Material, Value 1 ~ Value 15 (almost 1000 columns)

File B includes: Material, Character 1 ~ 3 (only 10 columns)

Only 1 argument, Material is common.

I've tried to combine two excel files but failed - impossible in matrix wise.

So, could you advise me to program this?

When I select Material in File A linking to many list boxes, the material selection for B is automatically set as same Material above.

I hope the description is enough to Catch what I am saying...

Thanks million.

S

Werner_E
24-Ruby V
(To:SKim)

S Kim wrote:

Me, again.

What can I do to apply for LOOKUP function in MC 15?

What exactly is the question concerning lookup? There are two of those functions in Mathcad, one is called "lookup", the other "Lookup" (capital L). What problem do you experience in using one of them?

I have 2 data files in excel.

File A includes: Material, Value 1 ~ Value 15 (almost 1000 columns)

File B includes: Material, Character 1 ~ 3 (only 10 columns)

OK, so when you read them in you have two matrices in Mathcad, matrix A is 15x1000 and matrix B is 3x10.

Only 1 argument, Material is common.

??? What does this mean? What are you trying to do with the two matrices?

I've tried to combine two excel files but failed - impossible in matrix wise.

How did you try and what failed?

So, could you advise me to program this?

When I select Material in File A linking to many list boxes, the material selection for B is automatically set as same Material above.

Sorry, I have no idea what you are trying to do. You will have to post a (trimmed down) example and explain concrete what you are trying to achieve. Better with data matrices already in Mathcad so we don't have to fiddle around with Excel files.

Ad combining the two matrices A and B with the dimensions described above.

You can do this but first you will have to turn matrix B from a 3x10 into a 3x1000 matrix. You do this by simply typing B[2,999:=0 (assuming ORIGIN is 0). Then you can use C:=stack(A,B) to combine the two matrices, if that is what you want to do.

The aforementioned method will fill the extra cells in the matrix with zeros. If that is not desireable and you want them filled with something else like "- - -", you will have to write a small routine with two nested loops which does the job or you use two range variables r:=15..17 and c:=10..999 and write C[r,c:="- - -" after you have used stack as above.

SKim
1-Newbie
(To:Werner_E)

Hello,

Pleas find the attached excel file.

There are 2 worksheets which I want to use "lookup" (sort of) function.

(I only thought of excel function name - lookup, I didn't know there were 2 different definition)

List is kinda back data, calc. is calculation parameter.

Except material name (mpp, kmp...), is nothing common between 2 worksheets.

But in one mathcad worksheet, I have to show all these data.

- I've made list boxes for the excel sheet "list" by getting your help.

- I have to put "calc." which is another sheet in excel in the same mathcad worksheet.

- as you said, the structures of 2 matrices are different, I could not combine both in one excel sheet.

- The data in calc. are used later for the calculation.

Since these should be synchronized too, I want to use list box in the same way of making list boxes above .

(When I made Excel file for all of this, I used "Index" function, so that I could bring up the values accordingly)

The picture I want to draw is,

list-1.jpgThis is the list box for excel sheet 'list'.

When I select material A here, another list box shows automatically the same material A even though it is not from the same excel (or data table) inserted in MC worksheet.

Sorry for so many ambiguous questions and thanks for your patience and attention.

Best regards,

S

Werner_E
24-Ruby V
(To:SKim)

You can combine the two tables. Either do it in Excel or after reading in the two tables you may also do it in Mathcad.

In "list"Insert three columns between the first and second column, then add all of "calc." on top.

Of course you could add the three data columns also after the last one if it is more appropriate for you to show those values last.

SKim
1-Newbie
(To:Werner_E)

is that still working even though I do not want to get those data in Calc. to be affected by the ones in "List" (aside from material)?

When it comes to the 'Calc. data', I am still wanting to use List box.

Currently,all the list boxes are followed by the previous definitions made up as list box.(data in list sheet)

After combining all, how can i put 'an exception' to these data from the routine? Can the 'Calc' data work separately without any influence of the others?

Werner_E
24-Ruby V
(To:SKim)

OK, so combining the tables is not an option. But you can use the same listbox call as for the selection of the properties in "list". SImply start a new series of list boxes - just without the first one (material selction)

The input value for the first listbox of the second series is then "Filter(Data2,stack(Material))", where Data2 is the matrix corresponding to your sheet "calc.".

SKim
1-Newbie
(To:Werner_E)

I, maybe, don't understand your guidance right.

Please see below.

1.jpg

Those are inserted data.

2 circled tables are list and calc. respectively mentioned earlier.

2.jpg

These are the list boxes deployed from Data. (1st red circled table - which was called as list.)

As you see, the 1st list box indicates "Material(A)".

3.jpg

These are the list boxes deployed from Z_diagram. (2nd red circled table- which was called as Calc.)

As you see, the 1st list box indicates "Material(B)".

Materials are same, but have different values in each deployment.

Materials are same, but have different values in each deployment.

So, What I am trying to do is, when choosing 1st Material(A), automatically Material(B) is set to the same value.

Is this Possible concept?

Werner_E
24-Ruby V
(To:SKim)

Materials are same, but have different values in each deployment.

Materials are same, but have different values in each deployment.

So, What I am trying to do is, when choosing 1st Material(A), automatically Material(B) is set to the same value.

Is this Possible concept?

Sure and I guess you will find some example in Richards collection of components which show how to (pre)select a certasin item in a listbox.

But why don't you simply omit the MatreialB listbox completely and use the material seleced in the first material-listbox in the listbox for Permeability, etc.?

SKim
1-Newbie
(To:Werner_E)

i want to go.. simple.. but my brain is not working for that now, sad friday.

Werner_E
24-Ruby V
(To:SKim)

S Kim wrote:

i want to go.. simple.. but my brain is not working for that now, sad friday.

??

You want to synchronize MaterialA and MaterialB.

As far as I see it the only one simple question which has to be answered is, if the user should have the option to chose MaterialB differently from MaterialA on some occasions.

If yes, some simple scripting would do the job, if no, you only need just one listbox for material.

SKim
1-Newbie
(To:Werner_E)

No, Only 1 time choice of material for 1 calculation.

However,

1 material has, for example, 20 sizes having different properties, while that material has other properties (u, f, etc.) regardless of the sizes.

When I have only 1 list box, how can i skip (or JUMP!) the whole properties to stack other ones?

then do i have to duplicate the properties 10 times if there are 10 columns (having other properties) for each material? on_

Werner_E
24-Ruby V
(To:SKim)

Clueless.

You have two tables A and B with materials and different properties. Materials are the same in both in the first column of each matrix, otherwise they are independend.

User selects a specific material and then should be able to select the appropriate properties from matrix A as I have shown in the sheet sent.

Additionally the user should be able to select the material properties from the matrix B, indepenedent (apart from the material) of what he has chosen from matrix A.

This is what I have understood so far.

If thats not what you are after, you should, as already advised, provide a small demo Mathcad demo sheet with the two matrices and explain in detail what you want to achieve (in Mathcad).

If thats what you want, all you have to do is to begin a new set of listboxes after the first set which choses from matrix A.

As the material is already selected, the second series begins with the listbox for the first property in matrix B. Just copy the second listbox of the first series and replace DataA with DataB in the Input field.

I had already suggest that above, so whats wrong with that approach?

To make it clear, the idea of merging the two tables into one died already long ago when you mentioned, that the properties in both tables are independend from each other.

SKim
1-Newbie
(To:Werner_E)

Werner,

Would you please take a look at the attachment?

Appreciate so much.

Werner_E
24-Ruby V
(To:SKim)

S Kim wrote:

Werner,

Would you please take a look at the attachment?

Appreciate so much.

I think I understood your problem already and my question was "whats wrong with omitting the material selection box in the second series of list boxes?".

I have assigned Md the value of Material, but of course you could have used Material itself in the last listboxes and get rid of Md completely.

1.png

One additional point: I see alot of list boxes which will present one value only. If you are absolutely sure, that a specific property will always be a unique value, whatever the user choses for the other and you think it doesn't make much sense to present a listbox where there is no choice, you may use something like Cd:=Filter(Z_diagram,stack(Md,ud,fd))[0 instead.

SKim
1-Newbie
(To:Werner_E)

Werner,

I didn't even think that it's possible.

Because despite the same material names, they locate in differnt tables..

I feel like I saw a light in a dark room.

Thanks a lot.

And regarding your kind advice, I will try to apply to the file when it's applicable.

Thanks!

S

Werner_E
24-Ruby V
(To:SKim)

S Kim wrote:

Werner,

I didn't even think that it's possible.

Because despite the same material names, they locate in differnt tables..

And the name is all that is used, so it should work. 😉

One thing is important: Every material name of the first table has to occur in the second table, too, and has to be written the very same way in both tables, otherwise you will experience an error.

Top Tags