-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbug_1.m
59 lines (42 loc) · 1.08 KB
/
bug_1.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
clear all
format compact
close all
pfiletype='-dpng';
pfileext='.png';
obj = @(x1,x2) x1^2+x2^2-2*x1-2*x2+2;
g3 = @(x1,x2) -.8-1/((x1)^3)+x2;
x1=linspace(0.01,8,91);
x2=linspace(0.01,8,95);
for i=1:length(x1)
for j=1:length(x2)
f(i,j)=obj(x1(i),x2(j));
con3(i,j)=g3(x1(i),x2(j));
end
end
x1 = exp(x1);
x2 = exp(x2);
c3=ocontourc(x1,x2',con3',[0 0]);
figure(1)
[c,h]=contour(x1,x2',f',[0.01 0.05 0.2 0.4, 0.8 1.6 3.2 6.4]);
hold on
tic
% This call is fast because the earlier call to contour established the
% axis limits as something reasonable for the data.
hatchedcontours(c3);
hold off
set(gca, 'XScale', 'log')
set(gca, 'YScale', 'log')
ax = axis;
toc
figure(2)
% This call is slow because without something to establish the axis limits,
% the default spc causes hatched line to create _way_ too many hatches.
% This causes slowdown or worse.
hatchedcontours(c3);
toc
hold on
[c,h]=contour(x1,x2',f',[0.01 0.05 0.2 0.4, 0.8 1.6 3.2 6.4]);
hold off
set(gca, 'XScale', 'log')
set(gca, 'YScale', 'log')
axis(ax)