findpeaks is in the Signal Processing Toolbox. If it is included on your license, you can install it using the Add-Ons Explorer.
The points are captured in variables [pk, loc] and [pkN, locN]. Your question didn't ask how to print them to the screen, but just remove the semicolon at the end fo those lines of code.
Otherwise, your approach is valid. You just need to account for all the points rather than just the first one. Here, I use the 2nd derivative to determine if the point is local min or max.
You will need Symbolic Math Toolbox to use the syms function, but you could use the islocalmin and islocalmax functions from MATLAB instead of findpeaks from Signal Processing Toolbox.
First plot the function and retrieve the coordinate data:
syms x y real
y=abs(x^3-9*x);
h = fplot(y, [-5 5]);
xdata = h.XData;
ydata = h.YData;
Find and plot the local minima. You would repeat these lines but replace islocalmin with islocalmax to find the local maxima.
You need to be careful when using fprintf() with multiple arguments that are non-scalar. fprintf() "consumes" all of the first parameter before moving on to all of the second parameter, and does so "down" columns first. That is why @Cris LaPierre constructed [xminima;yminima] which is two row vectors stacked on top of each other: going "down" the columns is picking out first an x and then a y, then back to the next x and the next y. The code as-is would not work properly if xminima and yminima started out as column vectors.
No, you cannot find intervals of increasing and decreasing with the code posted by @Steven Lord -- not without stripping down to all but the first 5 lines and then adding notable additional code.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.