- I am a new user of Scilab (see also here).
- I define a simple piece-wise function and get a confusing warning when I use the function (
"Warning adding a matrix with the empty matrix will give an empty matrix result."
). - Do you see where my mistake is?
function y = myTest(t)
// First Part
y(find(t < 0)) = 0;
// Middle Part
y(find(0 <= t & t <= 1)) = 1;
// Middle Part
ti3 = find(1 < t & t <= 3);
y(ti3) = -1*t(ti3) + 2;
// Middle Part
y(find(3 < t & t <= 4)) = -1;
// Middle Part
ti5 = find(4 < t & t <= 6);
y(ti5) = +1*t(ti5) -5;
// Middle Part
y(find(6 < t & t <= 8)) = 1;
// Last Part
y(find(8 < t)) = 0;
endfunction
myTest(1)
t = 0:0.1:10;
plot(t',myTest(t))
(Plot for myTest(t)
using t = 0:0.1:10
.)
(Confusing warning.)