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 sublim21  
#1 Posted : 29 May 2013 21:23:33(UTC)
sublim21


Rank: Advanced Member

Groups: Registered
Joined: 18/05/2011(UTC)
Posts: 36

Was thanked: 3 time(s) in 3 post(s)
Heya,

so here's my suggestion - hooked sections.

The idea is this,

lets say i have a section in a smath sheet

a:=5
b:=10

c:=a+b


what i'd like to do, is insert a 'hook' prior to this section

<hook 1>
a:=5
b:=10

c:=a+b

</hook 1>

so right now

c=15

what i'd like to do, is be able to call the hook section, with a:=9

hook1(a:9) -> c=19

the reason im suggesting this concept, is that sometimes, i'll write a section
that displays the information very nicely, but then i need to loop over the section with different variables.

This results in messy looking functions and loops, that i feel detract from the readability of the sheet.

By using hooked sections, i can display my methodology nicely, and still loop over the section with different variables.


I hope i've explained the concept well enough.

-Pete

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

Offline oscampo  
#2 Posted : 29 May 2013 21:41:41(UTC)
oscampo


Rank: Advanced Member

Groups: Registered
Joined: 10/12/2009(UTC)
Posts: 246
Man
Colombia
Location: Cali, Colombia

Was thanked: 85 time(s) in 65 post(s)
sublim21 wrote:

<hook 1>
a:=5
b:=10
c:=a+b

</hook 1>
so right now
c=15

what i'd like to do, is be able to call the hook section, with a:=9

hook1(a:9) -> c=19


In SMath you can define c as a function:

a:5

b:10

c(a;Cool:a+b

c(a;Cool=15

a:9

c(a;Cool=19

Regards,

Oscar
Offline mkraska  
#3 Posted : 29 May 2013 22:11:04(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
In fact, you even do not need a function, just symbolic expressions. If you re-define the independent variables, then just display the dependent ones again. There is no need to repeat the definitions, as would be required in most programming languages. In the example you can change the ODE coefficients without having them in the parameter list of D.

The odd thing is that this works only if D is defined with numeric optimization. Then the symbolic dependence is retained. If you use symbolic optimization, then the current (at definition time) values are hardwired and later changes do not have any effect.

Edited by user 29 May 2013 22:17:03(UTC)  | Reason: Not specified

File Attachment(s):
Example.sm (13kb) downloaded 38 time(s).
mkraska attached the following image(s):
Lorentz numeric.PNG
lorenz symbolic.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Users browsing this topic
Guest
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.