I have two list, x1 and d, I want to make a piecewise function out of them and plot it, but I may have some other stuffs like this so I decided to write this procedure in a proc, the proc makes the input of the piecewise right, but when I want to make a function out of this and pass it to plot this does not works properly, I tried something else; first assigned a seri to a variable and passed it to the piecewise to make a function out of it this does not works either, but when I write the seri directly into the piecewise it makes a function, what am I missing here? my worksheet is attached and the code is presented here
Vec2Pw.mw

![x1 := [seq(i-.5, i = 1 .. 10)]](/view.aspx?sf=132180/433151/b8ea0c9be00d7a011181984e02011f96.gif)
![[.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]](/view.aspx?sf=132180/433151/e6d22e7e4a7a9cbdf55e01a60a91b45f.gif)
|
(1) |
![d := [8.640000000, -.476000000, -.200000000, -.552000000, -4.248000000, -.192000000, -0.76000000e-1, .160000000, -3.056000000, 0.]](/view.aspx?sf=132180/433151/4f125b3cb6cdec659a2ff869da7c6f0b.gif)
![[8.640000000, -.476000000, -.200000000, -.552000000, -4.248000000, -.192000000, -0.76000000e-1, .160000000, -3.056000000, 0.]](/view.aspx?sf=132180/433151/81cb97c8328b9b00a726dbc3328e39c4.gif)
|
(2) |
![vec2pw := proc (L1::list, L2::list) local xn, yn, i, pw, x; xn := nops(L1); yn := nops(L2); pw := [`$`(0, 2*xn+2)]; if xn <> yn then print("Vectors dimensions are not consistent"); return pw end if; pw := x < (3/2)*L1[1]-(1/2)*L1[2], 0.; for i to xn-1 do pw := pw, x < (1/2)*L1[i]+(1/2)*L1[i+1], L2[i] end do; pw := pw, x < (3/2)*L1[xn]-(1/2)*L1[xn-1], L2[xn], 0.; return evalf(pw) end proc:](/view.aspx?sf=132180/433151/3a4a69c199548746de9b4b46f9f2b9ac.gif) 


|
(3) |


|
(4) |


|
(5) |


|
(6) |


|
(7) |

|
Download Vec2Pw.mw