# 留学生 实证 金融 风险var 事件研究法CAR 代写 蒙特卡罗 matlab

Min_x = min(Region1.Shifts(1, 1), Region2.Shifts(1, 1));
Max_x = max(Region1.Shifts(1, 2), Region2.Shifts(1, 2));
Min_y = min(Region1.Shifts(2, 1), Region2.Shifts(2, 1));
Max_y = max(Region1.Shifts(2, 2), Region2.Shifts(2, 2));

Image1 = zeros(Max_x-Min_x+3, Max_y-Min_y+3);
Image1(sub2ind(size(Image1), Region1.Boundary(1, :)-Min_x+2, ...
Region1.Boundary(2, :)-Min_y+2)) = 1;
Image1 = double(bwmorph(Image1, 'thicken'));
Image2 = zeros(Max_x-Min_x+3, Max_y-Min_y+3);
Image2(sub2ind(size(Image2), Region2.Boundary(1, :)-Min_x+2, ...
Region2.Boundary(2, :)-Min_y+2)) = 1;
Image2 = double(bwmorph(Image2, 'thicken'));

Image1 = Image1+Image2;

if length(find(Image1>1))>0 % there are some points with value of 2
else
end

if Region_left{I} == 0 % region was not chosen via "Select"
% prompt for an operation - one region only
Scr_sz = get(0, 'ScreenSize');
New_wind = dialog('Name', 'Choose region(s)', 'Position', ...
[Scr_sz(3)*0.3 Scr_sz(4)*0.4 Scr_sz(3)*0.3 Scr_sz(4)*0.1]);

k = 0;  Ok_button = 0; Interactive = 1;
if Show_all_regions{I} % not just active
k = Bndred_regions{I};
for i=1:Bndred_regions{I}
Regions_disp{i} = sprintf('%d', i);
end
else
for i=1:Bndred_regions{I}
if Regions{I}{i}.Private.Active
k = k+1;
Regions_disp{k} = sprintf('%d', i);
end
end
end

if k > 0
Region_left{I} = base2dec(Regions_disp{1}, 10); % to correspond
Choice_left = uicontrol('Parent', New_wind);
Call_back_left=sprintf('Segment_demo(''Left'',%18.16f,%d)', Choice_left, I);
set(Choice_left, 'Style', 'Popup', 'String', Regions_disp, ...
'Units', 'Normalized', 'Position', [0 0.5 0.45 0.5], ...
'Callback', Call_back_left);
Ok_button = uicontrol('Parent', New_wind, ...
'String', 'OK', 'Style', 'Pushbutton', ...
'Units', 'Normalized', 'Position', [0.1 0 0.3 0.4]);
end

Callback=sprintf('Segment_demo(''%s'',%d,%d)', 'Cancel operation', 0, I);
Cancel_button = uicontrol('Parent', New_wind, ...
'String', 'Cancel', 'Style', 'Pushbutton', 'Callback', Callback, ...
'Units', 'Normalized', 'Position', [0.6 0 0.3 0.4]);
else
Interactive = 0;
end