1 | function [H_new ny zero range eigvec]=update_hyperstate(H_old, ny)
|
---|
2 | H_new=zeros(size(H_old));
|
---|
3 | H_new(1,:,:)=H_old(1,:,:);
|
---|
4 | next_u=zeros(1,size(ny,2));
|
---|
5 |
|
---|
6 | %generate trajectories
|
---|
7 | for j=1:size(H_old,2)
|
---|
8 | eta=H_old(1,j,1);
|
---|
9 | beta=H_old(1,j,2);
|
---|
10 | best_control=-ny(1,j);
|
---|
11 |
|
---|
12 | for i=1:size(H_old,1)-1
|
---|
13 | s=randn;
|
---|
14 | pom=sqrt(1+best_control^2);
|
---|
15 | eta=abs(eta+beta*best_control+pom*s);
|
---|
16 | beta=abs(pom*beta+best_control*s);
|
---|
17 | H_new(i+1,j,:)=[eta beta];
|
---|
18 | if i+1<size(H_old,1)
|
---|
19 | index=find_in_hyperstate5([eta beta],H_old(i+1,:,:));
|
---|
20 | best_control=-ny(i,index);
|
---|
21 | end
|
---|
22 | end
|
---|
23 | end
|
---|
24 |
|
---|
25 | %make box
|
---|
26 | pom=zeros(size(H_new,2),2);
|
---|
27 | for i=2:size(H_new,1)
|
---|
28 | pom(:,:)=H_new(i,:,:);
|
---|
29 | [H_new(i,:,:) zero(i,:) range(i,:) eigvec(i,:,:)]=make_box4(pom); %rovnomerne rozmisti body v zasazenem regionu
|
---|
30 | %plot(H_new(i,:,1), H_new(i,:,2),'b.' ); hold on; plot(pom(:,1),pom(:,2), 'g.' ); plot(H_old(i,:,1),H_old(i,:,2), 'r.' ); hold off
|
---|
31 | end
|
---|
32 |
|
---|
33 | %kopirovani stareho ny* do H_new
|
---|
34 | for i=2:size(H_new,1)
|
---|
35 | for j=1:size(H_new,2)
|
---|
36 | pom(1,:)=H_new(i,j,:);
|
---|
37 | index=find_in_hyperstate5(pom,H_old(i,:,:));
|
---|
38 | next_u(j)=ny(i,index);
|
---|
39 | end
|
---|
40 | ny(i,:)= next_u;
|
---|
41 | end
|
---|
42 |
|
---|
43 | %vypis(:,:)=H_new(:,:,1);
|
---|
44 | %save 'eta2.txt' vypis -ASCII;
|
---|
45 | %vypis(:,:)=H_new(:,:,2);
|
---|
46 | %save 'Beta2.txt' vypis -ASCII;
|
---|
47 | % save 'ny2.txt' ny -ASCII;
|
---|
48 |
|
---|
49 | end
|
---|