π
<-
Chat plein-écran
[^]

Generate piecewise function from a BASIC program

Pour le TI-Basic sur Nspire

Generate piecewise function from a BASIC program

Unread postby fredrik.ekelof » 05 Nov 2019, 21:19

Hi

I would need some help on how to automatically generate a piecewise function from within a program written in TI-basic.

Scenario:

I have two list with numbers "xi" and "yi". From those lists I create a new list with several functions. Lets call the list "zi".

Now, I want my program to build up a peicewise function that shall be drawn using the graph app. The length of the piecewise function is not fixed. The number of "pieces can be anywhere between 2 and somewhere around 10.

Basically my problem is. How do I concatenate variables into a piecewise function?

Example of how the final result should work. The length/number of pieces
graph := piecewise(z[n],x[n] <= x <= x[n+1],z[n+1],x[n+1] <= x <= x[n+1].....)
User avatar
fredrik.ekelof
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 12.5%
 
Posts: 10
Joined: 09 Oct 2019, 13:37
Gender: Not specified
Calculator(s):

Re: Generate piecewise function from a BASIC program

Unread postby critor » 05 Nov 2019, 21:54

Hm, something like this ?
Image

Code: Select all
Define genpw(lx,lz)=
Prgm
:Local s
:s:="f(x):=piecewise("
:For i,1,dim(lz)
:  s:=s&when(i>1,",","")&string(lz[i])&","&string(lx[i])&"≤x≤"&string(lx[i+1])
:EndFor
:s:=s&")"
:expr(s)
:EndPrgm
Image
User avatar
critorAdmin.
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 2.5%
 
Posts: 34794
Images: 9172
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
Class: Lycée
YouTube: critor3000
Twitter: critor2000
Facebook: critor.ti

Re: Generate piecewise function from a BASIC program

Unread postby fredrik.ekelof » 05 Nov 2019, 22:14

Yes, perfect, thanks!
User avatar
fredrik.ekelof
Niveau 6: SM (Super Membre)
Niveau 6: SM (Super Membre)
Level up: 12.5%
 
Posts: 10
Joined: 09 Oct 2019, 13:37
Gender: Not specified
Calculator(s):


Return to Nspire-Basic

Who is online

Users browsing this forum: No registered users and 2 guests

-
Search
-
Featured topics
Omega, le fork étendant les capacités de ta NumWorks, même en mode examen !
Comparaisons des meilleurs prix pour acheter sa calculatrice !
12
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...

Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety 
-
Stats.
489 utilisateurs:
>479 invités
>5 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)