% Continuous Piecewise Function (Linear).
% With this function you can generate a Piecewise linear graph only
% with the points that unit the functions.
%
% [x,f(x)] = pwfun(xPoints,yPoints,number of samples,graph option);
%
% xPoints: Points of x axis.
% yPoints: Points of y axis.
% Numer of samples: Number of samples in x axis.
% Graph options:
%
% [x,f(x)] = pwfun(xPoints,yPoints,number of samples);
% Predefined form, plot with entire function.
%
% [x,f(x)] = pwfun(xPoints,yPoints,number of samples,1);
% Piecewise Function with different colours per function and legend with
% correspond function.
%
% [x,f(x)] = pwfun(xPoints,yPoints,number of samples,0);
% Without graph.
%
% Example:
%
% With this points
%
% (x1,y1) = (0,0)
% (x2,y2) = (4,10)
% (x3,y3) = (11,4)
% (x4,y4) = (15,-12)
% (x5,y5) = (23, 0)
% (x6,y6) = (25, 0)
%
% You can generate the next functions per intervals:
%
% f(x) = 2.5*x (0<x<4)
% f(x) = -0.857*x + 13.43 (4<x<11)
% f(x) = -4*x+48 (11<x<15)
% f(x) = 1.5*x-34.5 (15<x<23)
% f(x) = 0 (23<x<25)
%
% This function generates the functions in parts, only knowing the pair
% of points (xn, yn).
% In this case:
%
% xPoints = [0 4 11 15 23 25]; xPoints = [x1 x2 x3 x4 x5 x6]
% yPoints = [0 10 4 -12 0 0]; yPoints = [y1 y2 y3 y4 y5 y6]
%
% [x,y] = pwfun(xPoints,yPoints,1000);
%
% More examples in main.m
인용 양식
Setsuna Yuuki. (2024). Continuous Piecewise Function (Linear) (Función por partes) (https://www.mathworks.com/matlabcentral/fileexchange/83058-continuous-piecewise-function-linear-funcion-por-partes), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
플랫폼 호환성
Windows macOS Linux태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!