Continuous Piecewise Function (Linear) (Función por partes)

版本 1.2 (3.0 KB) 作者: Setsuna Yuuki.
With this function you can generate a Piecewise linear graph only with the points that unit the functions.
61.0 次下载
更新时间 2020/11/19

查看许可证

% 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 版本兼容性
创建方式 R2020b
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.2

.

1.1