π
<-

## Generate piecewise function from a BASIC program

Pour le TI-Basic sur Nspire

### Generate piecewise function from a BASIC program

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].....)

fredrik.ekelof

Niveau 6: SM (Super Membre)
Level up: 12.5%

Posts: 10
Joined: 09 Oct 2019, 13:37
Gender:
Calculator(s):

### Re: Generate piecewise function from a BASIC program

Hm, something like this ?

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

Niveau 19: CU (Créateur Universel)
Level up: 2.5%

Posts: 34794
Images: 9172
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender:
Calculator(s):
Class: Lycée

### Re: Generate piecewise function from a BASIC program

Yes, perfect, thanks!

fredrik.ekelof

Niveau 6: SM (Super Membre)
Level up: 12.5%

Posts: 10
Joined: 09 Oct 2019, 13:37
Gender:
Calculator(s):

### Who is online

Users browsing this forum: No registered users and 2 guests

-
Search
-
Featured topics
12
-
For more contests, prizes, reviews, helping us pay the server and domains...

Discover the the advantages of a donor account !

-
Featured files

-
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)