
How to plot a 3D cfit funktion in a 2d plot with isolines.
    7 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hi i have the following problem.
I fitted a curve with fit:
 it worked and that is my result:
     Linear model Poly23:
     sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p21*x^2*y 
                    + p12*x*y^2 + p03*y^3
     Coefficients (with 95% confidence bounds):
       p00 =       23.25  (-4.782, 51.29)
       p10 =      -13.85  (-28.85, 1.159)
       p01 =    -0.02275  (-0.0584, 0.01289)
       p20 =       5.615  (-2.615, 13.85)
       p11 =    0.006377  (-0.005635, 0.01839)
       p02 =   7.943e-06  (-6.068e-06, 2.195e-05)
       p21 =   -0.002272  (-0.004391, -0.000152)
       p12 =    7.47e-07  (-1.605e-06, 3.099e-06)
       p03 =  -5.769e-10  (-2.288e-09, 1.134e-09)
So now i want to plot the funtion. In 3D its easy (just plot(sf)),
but i want to have it in 2D with isolines:
       sf(x,y)=1200
       sf(x,y)=1660
       etc.
How can i do that.
contours seems not to work and plot3 either.
in the attachement is the sfit 1x1 for sf.
Greetings from Germany
0 Commenti
Risposte (1)
  Divyajyoti Nayak
 il 6 Set 2024
        From what I understand, you are trying to plot contours of different values for the surface defined by ‘sf.mat’. Like you mentioned, the ‘contour’ function cannot be used directly on ‘sf’, but we can recreate the fitted polynomial using the coefficients stored in ‘sf’ and then use the ‘contour’ function to get the isolines. Here’s a simple function to do this:
clc
clear
load 'sf.mat'
figure(1)
plot(sf);
isolines([20,30,40,50],sf)
function isolines(vals,sf)
    X = linspace(0,4);
    Y = linspace(0,4000);
    [x,y] = meshgrid(X,Y);
    %Recreating the fitted surface
    z = sf.p00 + sf.p10*x + sf.p01*y + sf.p20*x.^2 + sf.p11*x.*y + sf.p02*y.^2 + sf.p21*x.^2.*y + sf.p12*x.*y.^2 + sf.p03*y.^3;
    figure(2)
    contour(x,y,z,vals);
end
Here are the results:

0 Commenti
Vedere anche
Categorie
				Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

