Documente Academic
Documente Profesional
Documente Cultură
FI DE LABORATOR
%Datele experimentale
X1=[5 7 7 5 9 11 12 13 17 17 18 19];
X2=[2.9 2.5 3 1.5 4 4.5 5 5.5 6 7.5 8 7];
Y=[1 2 2.5 1.5 3.5 4 5 6 6.5 8 8 7.5];
X1=X1';
X2=X2';
Y=Y';
n=length(X1)
if exist('sympoly') == 2
model=polyn2sympoly(p)
end
if exist('sym') == 2
model=polyn2sym(p)
end
Metode numerice n ingineria electric- LUCRARI DE LABORATOR
pretty(model)
p. Coefficients
>> p. ModelTerms
ans =
X1 - exponent X2 -exponent
2 0 2 0
1 1 1 1
1 0 1 0
0 2 0 2
0 1 0 1
0 0 0 0
>> p. Coefficients
ans =
-0.0802 0.3131 0.7280 -0.3003 -0.4096 -1.4257
care nseamn
f ( x1, x 2) 0.0802 x12 0.3131x1 x 2 0.7280 x1 0.3003x 2 2 0.4096 x 2 1.4257
Metode numerice n ingineria electric- LUCRARI DE LABORATOR
f= p20*x(1)^2+p11*x(1)*x(2)+p10*x(1)+p02*x(2)^2+p01*x(2)+p00;
figure;
surf(xg,yg,reshape(zg,size(xg)))
hold on
plot3(xmin(1),xmin(2),fval,'ko','markersize',9,'MarkerFaceColor','black')
hold off
xlabel('Suma reclame TV');
ylabel('Suma reclame internet');
zlabel('Suma din vanzari');
rezultate:
xmin =
13.5000 7.5000
fval =
5.5234
Metode numerice n ingineria electric- LUCRARI DE LABORATOR
S (mp) 30 32 35 48 49 50 55 60 65 70 75 80 82 85 90
C 1 1 1 2 2 2 2 3 3 3 3 3 4 4 4
Y 30 29 31 36 38 40 48 47 53 49 58 60 59 71 65
(103 EUR)
Listing fiiere
Script:
%Datele experimentale
S=[30 32 35 48 49 50 55 60 65 70 75 80 82 85 90];
C=[1 1 1 2 2 2 2 3 3 3 3 3 4 4 4];
Y=[30 29 31 36 38 40 48 47 53 49 58 60 59 71 65];
S=S';
C=C';
Y=Y';
n=length(S)
if exist('sympoly') == 2
model=polyn2sympoly(p)
end
if exist('sym') == 2
model=polyn2sym(p)
end
pretty(model)
zg = polyvaln(p,[xg(:),yg(:)]);
figure;
surf(xg,yg,reshape(zg,size(xg)))
hold on
plot3(S,C,Y,'o')
hold off
xlabel('Suprafata');
ylabel('Nr camere');
zlabel('Pret vanzare');
Fiierul funcie funcoptim1 coninnd modelul de regresie:
function f=funcoptim1(x)
p20= 0.0042;
p11= -0.3474;
p10= 1.1384;
p02= 5.6115;
p01= -9.4919;
p00= 3.9128;
f=
p20*x(1)^2+p11*x(1)*x(2)+p10*x(1)+p02*x(2)^2+p01*x(2)+p00;
end
Fiierul funcie coninnd restriciile:
function [c, ceq]=conoptim1(x)
% restrictii neliniare de inegalitate
c=[55-x(1);x(1)-75;3-x(2);x(2)-4];
% restrictii neliniare de egalitate
ceq=[];
end
Fiierul surs pentru problema de optimizare:
%Determinarea minimului
figure;
surf(xg,yg,reshape(zg,size(xg)))
hold on
plot3(xmin(1),xmin(2),fval,'ko','markersize',9,'MarkerFaceColor','black')
hold off
xlabel('Suma reclame TV');
ylabel('Suma reclame internet');
zlabel('Suma din vanzari');
Metode numerice n ingineria electric- LUCRARI DE LABORATOR
Afisare rezultate
>> p. ModelTerms
>> p. Coefficients
/*
ans = 0.0042 -0.3474 1.1384 5.6115 -9.4919 3.9128
rezultate:
xmin =
55.0000 3.0000
fval =
43.9366
Metode numerice n ingineria electric- LUCRARI DE LABORATOR
b)
C=4
clc,clear all
%Datele experimentale
S=[30 32 35 48 49 50 55 60 65 70 75 80 82 85 90];
C=[1 1 1 2 2 2 2 3 3 3 3 3 4 4 4];
Y=[30 29 31 36 38 40 48 47 53 49 58 60 59 71 65];
S=S';
C=C';
Y=Y';
n=length(S)
if exist('sympoly') == 2
model=polyn2sympoly(p)
end
if exist('sym') == 2
Metode numerice n ingineria electric- LUCRARI DE LABORATOR
model=polyn2sym(p)
end
pretty(model)
p. Coefficients
>> p. ModelTerms
>> p. Coefficients
/*
ans = 0.0042 -0.3474 1.1384 5.6115 -9.4919 3.9128
*/
p20= 0.0042;
p11= -0.3474;
p10= 1.1384;
p02= 5.6115;
p01= -9.4919;
Metode numerice n ingineria electric- LUCRARI DE LABORATOR
p00= 3.9128;
f= p20*x(1)^2+p11*x(1)*x(2)+p10*x(1)+p02*x(2)^2+p01*x(2)+p00;
end
Fiierul funcie coninnd restriciile:
function [c, ceq]=conoptim1(x)
% restrictii neliniare de inegalitate
%c=[55-x(1);x(1)-75;3-x(2);x(2)-4];
% restrictii neliniare de egalitate
c=[];
ceq=[x(2)-4];
end
Fiierul surs pentru problema de optimizare:
%Determinarea minimului
figure;
surf(xg,yg,reshape(zg,size(xg)))
hold on
plot3(xmin(1),xmin(2),fval,'ko','markersize',9,'MarkerFaceColor','black')
hold off
xlabel('Suma reclame TV');
ylabel('Suma reclame internet');
zlabel('Suma din vanzari');
rezultat
xmin =
29.9048 4.0000
fval =
51.9732
Metode numerice n ingineria electric- LUCRARI DE LABORATOR