Effacer les filtres
Effacer les filtres

fit a 3d curve

181 vues (au cours des 30 derniers jours)
Elza
Elza le 14 Avr 2011
Réponse apportée : Sonali le 27 Août 2023
Dear all,
I am a beginner in Matlab and I need your help. Here is my problem: I have a cloud of data obtained by measurement. Thanks to those datas I have made a matrix(49x49) which allowed me to plot a paraboloid. I would like to fit this 3d curve based on data, but I don't know how to start. Could you please help me to find a way to solve this problem?
Sincerely,
Elza
  1 commentaire
marcelo matos
marcelo matos le 29 Sep 2015

Connectez-vous pour commenter.

Réponse acceptée

Andrew Newell
Andrew Newell le 14 Avr 2011
Modifié(e) : John Kelly le 12 Juin 2014
If you have the Curve Fitting Toolbox, you could try interactive surface fitting.
EDIT: If you don't have it, you could try polyfitn, which you can download from the File Exchange.

Plus de réponses (4)

Elza
Elza le 14 Avr 2011
Many thanks for your answer. Actually I don't have this tool. Do you know an other way to do it?
Thanks a million.
Elza

Jarrod Rivituso
Jarrod Rivituso le 14 Avr 2011
Could you cast it as a linear regression problem and then solve the equations using backslash? Some details:
Say we are trying to fit to an equation of the form
z = c1*f1(x,y) + c2*f2(x,y) + ...
where f1 and f2 are the basis functions of the linear equation, and c1,c2,etc. are the coefficients. You could write this as a matrix equation...
z = [f1(x,y) , f2(x,y) , ...] * [c1 ; c2 ; ...]
Here's an example in MATLAB with some data I made up...
%Define grid of x,y values
x = -1:0.01:1;
y = -1:0.01:1;
[X,Y] = meshgrid(x,y);
%Make up some data
data = X.^2 + 3*Y.^2 + 0.01*rand(size(X));
%Set the basis functions
f1 = ones(size(X));
f2 = Y.^2;
f3 = X.^2;
%Write as matrix equation
A = [f1(:),f2(:),f3(:)];
y = data(:);
%Solve for coefficients
coeffs = A\y

Elza
Elza le 20 Avr 2011
Thanks for your help Jarrod, I'll try that and let you know if it works for me.
Many thanks
  1 commentaire
Benjamin Lewis
Benjamin Lewis le 24 Sep 2020
did it work?

Connectez-vous pour commenter.


Sonali
Sonali le 27 Août 2023
Rt = 30.5;
area_ratio = 31.4754;
theta = 50;
theta_exit = 16.5;
theta_n = theta*pi/180;
k = 0.8;
Ln = k*(sqrt(area_ratio)-1)*Rt/tand(theta_exit);
% FIRST CURVE (FC)
% Angles for First Curve
Angle_FC = -(pi+(45*pi/180));
FC_step = (-pi/2-Angle_FC)/100;
theta_FC = (-3*pi/4):FC_step:(-pi/2);
% Coordinates for First Curve
x_FC = cos(theta_FC)*1.5*Rt;
y_FC = sin(theta_FC)*1.5*Rt+(1.5*Rt+Rt);
x_FC1 = x_FC';
y_FC1 = y_FC';
% SECOND CURVE (SC)
% Angle for Second Curve
Angle_SC = -pi/2;
SC_step = ((theta_n-pi/2)-Angle_SC)/100;
theta_SC = -pi/2:SC_step:(theta_n-pi/2);
% Coordinates for Second Curve
x_SC = cos(theta_SC)*0.382*Rt;
y_SC = sin(theta_SC)*0.382*Rt+(0.382*Rt+Rt);
x_SC1 = x_SC';
y_SC1 = y_SC';
% THIRD CURVE (TC)
% Coordinates for Third Curve
x_TC = cos(theta_n-pi/2)*0.382*Rt;
y_TC = sin(theta_n-pi/2)*0.382*Rt+(0.382*Rt+Rt);
% Exit Coordinates
y_exit = sqrt(area_ratio)*Rt;
matrix_y = [y_TC^2 y_TC 1; y_exit^2 y_exit 1; 2*y_TC 1 0];
matrix_x = [x_TC; Ln ;1/tan(theta_n)];
x_exit = matrix_y^-1*matrix_x;
a = x_exit(1,1);
b = x_exit(2,1);
c = x_exit(3,1);
y = y_TC:0.8:y_exit;
x = a*y.^2+b*y+c;
% Complete Coordinate
Rao_x = [x_FC x_SC x];
Rao_y = [y_FC y_SC y];
% Lower Geometry
Rao_y1 = -1*Rao_y;
%Coordinates
R_X = Rao_x';
R_Y = Rao_y';
Rao = [R_X R_Y];
% Figures
figure(1)
plot (Rao_x,Rao_y,'r','LineWidth',3)
hold on
plot (Rao_x,Rao_y1,'r','LineWidth',3)
hold of
I need this code To be generate in 3D model
can you please provide

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by