plotting quadratic equation and curve fittting

im kinda of struck how to plot quadratic function for different x and y values.the equation is (x^25)+(y^3)-(6*x^24*y) for different values of x =[-10,10] and y=[-10,10] and do a polyfit for the obtained point

 Accepted Answer

The plot is straightforward:
fcn = @(x,y) (x.^25)+(y.^3)-(6*x.^24.*y);
[X,Y] = meshgrid(-10:0.5:10);
figure(1)
meshc(X, Y, fcn(X,Y))
grid on
xlabel('X')
ylabel('Y')
I do not know the reason you would want to fit this with polyfit. You already have the equation for the surface.

8 Comments

i wanted points for different vales of x and y if we plug x's and y's in eqn we will get value and that value needs to be plotted in graph ,so we will get number of points from that equation and i want a curve that passed through these points
ps i dont need 3d graph , i need values in cs x values for horizontal axis and y values for vertical axis thankyou
Please clarify what you want. Your original Question and the first part of your Comment asked for exactly what my code provided.
I do not understand your ‘ps’. It does not make sense.
i am sorry but i didnt run the code ,i just saw the code and asked ,now i runned the code i need only the curve lines (xy plane) not the surface how to do that?
The xy plane the function uses are defined by the ‘X’ and ‘Y’ outputs of meshgrid.
my friend i am new to matlab maybe i am conveying you wrong , i know that the surface is projected on plane so we get those curves.i need only the highlighted part not the surface maybe a transparent surface but a visible color curves ,is that possible? thankyou
The plot you want is the contour function to only plot the contours.
The plot you show was produced by the meshc function. It draws the surface and the contours.
A quite good. but cammand for equation, F(x) = x^3+ 2x+1
@M — Your function is not appropriate for this code, since it has only one variable and this code requires functions with two variables.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!