y = (x-1)^3 / x^2 graph in matlab

To plot the function y = ((x-1)^3)/x^2 in MATLAB, you can use the following code:

main.m
fplot(@(x) ((x-1)^3)/x^2, [-5 5])
34 chars
2 lines

The fplot function is used to plot a function over a given range. Here, we define the function inline using the @(x) syntax, which allows us to input values of x and evaluate the function. The range for x is defined as [-5, 5].

Alternatively, you can define the function as a separate function file and call it from the fplot function. Here's an example:

main.m
% Define the function in a separate file, "myfun.m"
function y = myfun(x)
    y = ((x-1).^3)./x.^2;
end

% Call the function using fplot
fplot(@myfun, [-5 5])
159 chars
8 lines

Either way, the resulting graph should look like this:

Matlab Graph

gistlibby LogSnag