I would like to plot the shifted logistic function as shown from Wolfram Alpha.
In particular, I would like the function to be of the form
y = exp(x - t) / (1 + exp(x - t))
where t > 0. In the link, for example, t is 6. I had originally tried the following:
x = 0:.1:12;
y = exp(x - 6) ./ (1 + exp(x - 6));
plot(x, y);
axis([0 6 0 1])
However, this is not the same as the result from Wolfram Alpha. Here is an export of my plot.
I do not understand what the difference is between what I am trying to do here vs. plotting shifted sin and cosine functions (which works using the same technique).
I am not completely new to Matlab but I do not usually use it in this way.
Edit: My values for x in the code should have been from 0 to 12.
fplottakes as inputs a function handle and a range to plot for:>> fplot(@(x) exp(x-6) / (1 + exp(x-6)), [0 12])The beauty of
fplotin this case is you don’t need to spend time calculating y-values beforehand; you could also extract values from the graph after the fact if you want (by getting the line handle‘sXDataandYDataproperties).