1 страниц (3 вхождений)
Include Hook Sections - Redfine variables with hooks - Сообщения
#1 Опубликовано: 29.05.2013 14:23:33
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
a:=5
b:=10
c:=a+b
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
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
a:=5
b:=10
c:=a+b
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
#2 Опубликовано: 29.05.2013 14:41:41
Wrote
a:=5
b:=10
c:=a+b
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:
[MATH]a:5[/MATH]
[MATH]b:10[/MATH]
[MATH]c(a;b):a+b[/MATH]
[MATH]c(a;b)=15[/MATH]
[MATH]a:9[/MATH]
[MATH]c(a;b)=19[/MATH]
Regards,
Oscar
#3 Опубликовано: 29.05.2013 15:11:04
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.

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.
Martin Kraska
Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 страниц (3 вхождений)
-
Новые сообщения
-
Нет новых сообщений