x = linspace(0,1);ytest = piecewise1(x);plot(x,ytest)function ytest = piecewise1(x)if 0<x<0.04 ytest = piecewise(x);elseif 0.04<x<0.08 ytest = piecewise(x-0.04);elseif 0.08<x<0.1 ytest = piecewise(x-0.08);elseif 0.1<x<1 ytest = 0;endendfunction w = piecewise(x);w(0<=x & x<0.005) = 6;x1 = x(0.005<=x & x<=0.015);w(0.005<=x & x<=0.015)= (60000*(x1.^2)-1800*x1+13.5);x2 = x(0.015<=x & x<=0.025);w(0.015<=x & x<=0.025) = 0;x3 = x(0.025<=x & x<=0.035);w(0.025<=x & x<=0.035) = -3*sin(300*3.14*(x3-0.025));x4 = x(0.035<=x & x<=0.04);w(0.035<=x & x<=0.04) = 6*sin(100*3.14*(x4-0.035));end
MATLAB: Can I not call a function inside another function?? getting “Output argument “ytest” (and maybe others) not assigned during call to “test>piecewise1″.” as error
calling functionsdspfunctionspiecewise functions
Best Answer