Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline sinneD  
#1 Posted : 06 July 2018 21:31:10(UTC)
sinneD


Rank: Advanced Member

Groups: Registered
Joined: 12/03/2011(UTC)
Posts: 101
Location: Chicago

Was thanked: 16 time(s) in 7 post(s)
Greetings all-

I am trying to implement either a Combobox or ComboBoxList. I can not determine which one is best suited for my application.

The only discussion I can find is for List-
https://en.smath.info/fo...ComboBoxList-Region.aspx

Is there something for plain ComboBox? I tried searching the forum, wiki and the samples, but no luck.

I am trying to calc a wind force coefficient based on if the object is flat or round- here is what I have come up with so far.



I feel like there might be a better or cleaner syntax.

Why would you choose one over the other? Can anyone suggest an alternate or better method for doing this?

Thanks in advance

Dennis
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline PompelmoTell  
#2 Posted : 07 July 2018 00:23:33(UTC)
PompelmoTell


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2011(UTC)
Posts: 318
Man
Italy
Location: italy

Was thanked: 109 time(s) in 93 post(s)
Two partially contradictory aspects do not convince me:
First calculate all the values ​​(2 in your example) but only one you need. In general, it could be very expensive in some cases.
Also use the same variable name for the array and for the output value from the combobox. This way you will no longer have the calculated values ​​available for any further evaluation.
I prefer to create a function with several variables to be used if necessary. I used the "cases" function (of the Custom Functions plugin by Davide Carpi) but you can also use if ... else...)
You can still use the combobox to select a parameter and assign it to a variable to be used in the function.
sergio
Offline sinneD  
#3 Posted : 09 July 2018 05:29:37(UTC)
sinneD


Rank: Advanced Member

Groups: Registered
Joined: 12/03/2011(UTC)
Posts: 101
Location: Chicago

Was thanked: 16 time(s) in 7 post(s)
Car_Sample.sm (13kb) downloaded 75 time(s).PompelmoTell-

I did not consider as you suggested for defining it as a custome fuction. I am confused by the "#" in your example. Can you direct me to reference so I can understand the syntax? I thought we could define the inputs and create the function as

function(a, b, c)=a^2+2*b+c

I tried to do this logic by trying to implement the "line" function but could not get it to work. I only could get it to work with if-then statments.

I did not consider the effect of calculating both conditions. I do not know what kind of overheaad that may generate but your point is very much appreciated.

I am not sure that I understand what you mean by using the same value for the variable and the array name. It may be that it was only how I got it to work a the time, I will attempt to revise it.

I may have 4-25 different components to evaluate within the same Page, so I am trying to define the variable and call it up time and time again. Typically, I will insert a 'Seperator' into the document to start a new physical page, and then define the next antenna or device dimensions, manually indexing the i'th values, and computing the Car, then the Area and so forth to get F.i fo the item.

Here is an example of how it was done with MathCad- https://imgur.com/r4AZAAJ . (I have tried to edit out the extraneous info and only include the relavent calculation and logic for Ca).

MathCAd example

Attached is my curent snippet - https://imgur.com/ojZEdLb

As you can see, its a bit ugly. I have attached the code in the snippet as well. Car_Sample.sm (13kb) downloaded 75 time(s).

Car Calc Logic

My hope is to ultimatly be able to define a matrix either in Excel or within SMath to then compute the values in bulk. My programming skills are weak and I am doing my best learning little by little as I go.

I think your suggestion will work out better than manually doing it page by page. I need to come up with a loop to read the lines of the array and do the calculation.

I would appreciate any other suggestions you may have.

Dennis






Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
Offline PompelmoTell  
#4 Posted : 09 July 2018 14:33:40(UTC)
PompelmoTell


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2011(UTC)
Posts: 318
Man
Italy
Location: italy

Was thanked: 109 time(s) in 93 post(s)
Dennis,
# It's just a character like the others. I use it to distinguish the variables of functions in their definition.
You used the C.AR variable a first time to evaluate a matrix. Right after that you used the same variable name as the ComboBox output and would associate one of the matrix values. At this point for all subsequent operations you have destroyed the initial matrix.

sergio
thanks 1 user thanked PompelmoTell for this useful post.
on 09/07/2018(UTC)
Offline sinneD  
#5 Posted : 10 July 2018 00:59:48(UTC)
sinneD


Rank: Advanced Member

Groups: Registered
Joined: 12/03/2011(UTC)
Posts: 101
Location: Chicago

Was thanked: 16 time(s) in 7 post(s)
Sergio-

I got the variables redefined properly. I see what you mean now.

I had some difficulty with the cases function- I could not figure out how to get another entry in the list. I though it might use the handle like in matrix or line function, but could not figure it out. I ended up copying the 3 line example but would really prefer to learn it properly. Any tips on adding or removing lines to the function?

I also broke apart the page into 2 and put all the matricies and equations into another page that i am calling with an include statement- it makes for a much cleaner end result.

Dennis
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
Offline PompelmoTell  
#6 Posted : 10 July 2018 11:46:00(UTC)
PompelmoTell


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2011(UTC)
Posts: 318
Man
Italy
Location: italy

Was thanked: 109 time(s) in 93 post(s)
at the end of the line insert twice arguments separator (";" or "," depending on the settings)

sergio
Offline sinneD  
#7 Posted : 03 August 2018 19:24:40(UTC)
sinneD


Rank: Advanced Member

Groups: Registered
Joined: 12/03/2011(UTC)
Posts: 101
Location: Chicago

Was thanked: 16 time(s) in 7 post(s)
How can we insert another line into the cases function?
I can not seem to get the cursor in the right place to add another case.

For the life of me, I can not find the custom function plugin forum page or example worksheet. Can anyone give me some tips?

Thanks
Dennis
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
Offline alyles  
#8 Posted : 03 August 2018 20:24:51(UTC)
alyles


Rank: Advanced Member

Groups: Registered
Joined: 23/03/2016(UTC)
Posts: 275
United States

Was thanked: 91 time(s) in 57 post(s)
anywhere within the cases() function just hit the comma twice. You are really adding two arguments.... the result, and the condition.

Edit: I said comma, but I should say your argument separator which could be a semi-colon depending on your settings.

Edited by user 03 August 2018 21:32:37(UTC)  | Reason: Not specified

Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
thanks 1 user thanked alyles for this useful post.
on 04/08/2018(UTC)
Offline sinneD  
#9 Posted : 04 August 2018 02:05:14(UTC)
sinneD


Rank: Advanced Member

Groups: Registered
Joined: 12/03/2011(UTC)
Posts: 101
Location: Chicago

Was thanked: 16 time(s) in 7 post(s)
thanks, i was only inserting one separator.
Join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
Offline Jean Giraud  
#10 Posted : 04 August 2018 15:51:10(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: sinneD Go to Quoted Post
thanks, i was only inserting one separator.


Another virtue of the coma

IntSuite.PNG
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.