What is the best function of the following shape?
Show older comments
How can I construct this shape? what is the best function of it?
It is more like sigmoid function + straight line
But I cant get how can I represent it by one equation and How to control its limits!
The Y limits should be from 0 to 1
( I want to use it as a fuzzy memebership function)
Is there any recommendation?

2 Comments
Not exactly sure what you want to do because you didn't define the problem in a mathematical manner. The existing functions in the Fuzzy Toolbox library stock do not have cutoff points. Guess you want to create a custom Sigmoidal Membership Function with one-sided cutoff point for your unique Fuzzy System, where it can be rescaled and reflected in anyway you want:
M
on 7 Sep 2022
Accepted Answer
More Answers (4)
x = -2:0.01:2;
plot([x,x(end)],[1/pi*atan(2*x)+1/2,1/pi*atan(2*x(1))+1/2])
xlim ([-3 3])
ylim ([0 1])
14 Comments
M
on 6 Sep 2022
M
on 6 Sep 2022
Torsten
on 6 Sep 2022
The function is written in the plot.
If you plot the function in a subinterval, you get the plot of the function in the subinterval. What do you expect without changing the function itself ?
x = 0:0.01:1;
plot([x,x(end)],[1/pi*atan(10*(x-0.5))+0.5,1/pi*atan(10*(x(1)-0.5))+0.5])
xlim ([0 1.1])
ylim ([0 1])
M
on 6 Sep 2022
Torsten
on 7 Sep 2022
Not possible with this function - it goes asymtotically against 0 and 1.
Use Sam Chak's solution instead.
M
on 7 Sep 2022
M
on 7 Sep 2022
Try this:
xmin = 1;
xmax = 3;
pp = struct('form','pp',...
'breaks',[-1e-100 0 1 inf],...
'coefs',[0 0 0 0 0 0;6,-15,10,0,0,0;0 0 0 0 0 1],...
'pieces',3,...
'order',6,...
'dim',1);
sfun = @(x) ppval(pp,(x-xmin)/(xmax-xmin));
ezplot(sfun,xmin-1,xmax+1)
13 Comments
M
on 7 Sep 2022
Bruno Luong
on 7 Sep 2022
It's exact same Sam Chack's when you look carefull the coefficients, and extended also on the left/right sides of the x boundaries.
M
on 7 Sep 2022
Sam Chak
on 8 Sep 2022
Yes, @Bruno Luong, the methods are the same. In fact, you posted the Answer 5 min earlier than me. Thanks as I learned something new about ppval() from you.
However, the fixed 5th-order polynomial trajectory generation approach does not allow the S-curve to be adjusted. An option for @M to choose between the 5th-, 7th,- and 9th-order would probably allow some flexiness.
M
on 11 Sep 2022
Bruno Luong
on 11 Sep 2022
Edited: Bruno Luong
on 11 Sep 2022
My function sfun has constant value of 0 for x <= xmin and 1 for x >= xmax.
The function graph are therefore straignt lines in those domain.
M
on 11 Sep 2022
Bruno Luong
on 11 Sep 2022
If you want the function to be 0 for x >= xmax, set the last value of 'coefs' to 0.
"In mathematics, a function from a set X to a set Y assigns to each element of X exactly one element of Y."
You ask for function. I give you a code that provide a function with real input x that drops to 0 at xmax.
If you want to do something else with the function, you are free to do it on top of my function sfun.
If you don't want the tail just plot in the ROI
xmin = 1;
xmax = 3;
pp = struct('form','pp',...
'breaks',[-1e-100 0 1 inf],...
'coefs',[0 0 0 0 0 0;6,-15,10,0,0,0;0 0 0 0 0 0],...
'pieces',3,...
'order',6,...
'dim',1);
sfun = @(x) ppval(pp,(x-xmin)/(xmax-xmin));
close all
x = linspace(xmin,xmax,2^12+1);
plot(x,sfun(x),'linewidth',2)
xlim([0 4])
Walter Roberson
on 12 Sep 2022
In analysis, a "function" is any mapping of values to other values. It might or might not be "one to one" or "onto". There is no requirement that the function maps all possible inputs in the domain.
In analysis, functions over infinite sets are treated like the limit of finite mappings. For example, x->x^2, x in Z, is treated as-if it were the set of mappings {..., -2 -> 4, -1 -> 1, 0 -> 0, 1 -> 1, 2 -> 2, ...} rather than as being something fundamentally different. There does not have to be a formula for a function: the complete list of mappings defines the function; formulae can make it significantly more compact to express though. The mappings are the fundamental property of the function; formulae are conveniences to express mappings.
Bruno Luong
on 12 Sep 2022
Edited: Bruno Luong
on 12 Sep 2022
"There is no requirement that the function maps all possible inputs in the domain."
Wrong to my book, all elements of input set (domain) must be mapped (defined) by the function.
Walter Roberson
on 6 Sep 2022
1 vote
Looks like tansig
2 Comments
Image Analyst
on 12 Sep 2022
James Tursa
on 6 Sep 2022
Edited: James Tursa
on 6 Sep 2022
1 vote
There are lots of functions that could fit this general shape. E.g., sin(x), or more generally A*sin(B*x+C) depending on width and height of the graph which you don't show. Maybe you could share some more details about where this shape comes from and the height and width sizes.
3 Comments
Image Analyst
on 12 Sep 2022
@M there are a variety of equations that can do that. See
and just pick one.
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!










