Question No. 1 .
(1)
A(Save as afun1.m)
function f = Afun1 (x);
f= (x^2-1) * (x<=-5) + (X*cos (x)) * (x>-5&x<5) + (x+5) * (x>=5);
B [Email protected] (x) (x^2-1) * (x<=-5) + (X*cos (x)) * (x>-5&x<5) + (x+5) * (x>=5);
C [Email protected] (x) (x.^2-1). * (x<=-5) + (X.*cos (x)). * (x>-5&x<5) + (x+5). * (x>=5);
(2)
A
Clc,clear
A=1;
X=[-15:0.1:15];
While a<=301
Z (a) =afun1 (x (a));
a=a+1;
End
Z
B
Clc,clear
[Email protected] (x) (x^2-1) * (x<=-5) + (X*cos (x)) * (x>-5&x<5) + (x+5) * (x>=5);
A=1;
X=[-15:0.1:15];
While a<=301
Z (a) =y (x (a));
a=a+1;
End
Z
C x=[-15:0.1:15]; Z=y (x);
(3)
A:fplot (' Afun1 ', [ -15,15]);
B,C: fplot (y,[-15,15]);
(4)
On the basis of the second question code
A,B:plot (x,z);
C: plot (x,z);
question No. 2
Rand (' state ', sum (clock));
A=rand (3,5);
B=rand (4,7);
C=rand (6,9);
Ma=max (Max (a));
[Ax,ay]=find (A==max (Max (a)));
Mb=max (max (b));
[Bx,by]=find (B==max (max (b)));
Mc=max (Max (c));
[Cx,cy]=find (C==max (Max (c)));
question No. 3
[Email protected] (x) sin (x). *x;
Fplot (y,[0,100]);
% has a minimum point
% Estimated position
Clc,clear
[Email protected] (x) sin (x). *x;
X0=[5,10,18,22,30,37,41,49,55,61,68,74,80,87,92,99];
[X1,yval]=fminunc (' Y ', 5);
Question Fourth
Give the Model:
(symbol description)
Model
Give the code:
Clc,clear
c=[1,0,0,0,1,0,1,0;
1,1,0,0,1,0,0,1;
1,0,1,0,1,0,0,0;
0,1,0,1,0,0,0,1;
0,0,1,0,0,1,0,0;
0,0,0,1,0,1,0,1;
];
C=-c;
C=c ';
%c ' is a
B=ones (8,1);
B=-b;
F=ones (6,1);
Ub=ones (6,1);
Lb=zeros (6,1);
Intcon=1:6;
[X,val]=intlinprog (F,intcon,c,b,[],[],lb,ub);
Result of Operation:
X =[1,0,0,1,1,0] '
val = 3;
"Problem Transformation"
The number of the students to 34,29,42,21,56,18,71 The point marking for 1~7,
Set 1~2,3; 2~3,4,5; 4~5,6,7; 5~6;6~7 's Edge marking is 1~11
Then The weight of the first edge is 63,76,71,50,85,63,77,39,92,74,89
You can prove that you should not take a heavy vertex.
The problem is converted to two on this side of the line , in the case of not taking the heavy vertex, the maximum weight of the two edges
"Symbol description"
the weight of the side of the section I is represented by fi
Xi represents whether Iis selected (is 1, no 0)
"Build Model"
Max Fi*xi
s.t
"Code as follows"
Clc,clear
f=[-63;-76;-71;-60;-85;-63;-77;-39;-98;-74;-89];intcon=11;
A=[1 1 0 0 0 0 0 0 0 0 0;
1 0 1 1 1 0 0 0 0 0 0;
0 1 1 0 0 1 0 0 0 0 0;
0 0 0 1 1 1 1 1 1 0 0;
0 0 0 0 1 0 1 0 0 1 0;
0 0 0 0 0 0 0 1 0 1 1;
0 0 0 0 0 0 0 0 1 0 1];
B=ones (7,1);
Aeq=ones (1,11); beq=2;
Lb=zeros (11,1); Ub=ones (11,1);
[X,fval]=intlinprog (F,intcon,a,b,aeq,beq,lb,ub)
Val=-fval
"The results are as follows"
Lp:optimal objective value is-174.000000.
X =[0 1 0 0 0 0 0 0 1 0 0] '
FVal =-174
Val =174
My homework.