我有两个观察者通过Prototype JavaScript框架的clc;clear all;
syms x t k;
b=0.53;T=2;
tol=0.0001;
phi=sqrt(2)*sin(k*pi*x);
alphax=x^2*(x-1)^2;
betax=-2*x*(x-1);
phi1=sqrt(2)*sin(k*pi*b);
%% initialisation de lambda et z
lambda_pr=x;
z_pr=-1*x*(x-1);
%%iteration1
for m=1:10
% use 10 iteration just for test, it can be more
% in the second iteration i got the error here
prim=int(phi*lambda_pr,x,0,1);
u=-symsum(((exp((-k^2*pi^2)*(T-t))*phi1)*prim),k,1,10);
z_max=lambda_pr + z_pr-alphax;
z_min=lambda_pr + z_pr-betax;
z_max=matlabFunction(-1*z_max);%convert to matlab function
z_min=matlabFunction(z_min); %convert to matlab function
[xMin, minValue] = fminbnd(z_min, 0, 1);
[xMax, maxValue] = fminbnd(z_max, 0, 1);
if maxValue<0
z_new=alphax;
elseif minValue>0
z_new=betax;
else
z_new=z;
end
%ecart
ecart=(z_new-z_pr)^2;
err=double((int(ecart,0,1))^(0.5))
if err>tol
%here where i have the problem
primt=int(exp((-k^2*pi^2)*(2-t))*u,t,0,2));
lambda_pr = lambda_pr + symsum(primt,k,1,10)-z_new;
z_pr=z_new;
end
end
函数注册。两个观察者都在同一元素上观察同一事件。第二个观察者由第三方库注册,它执行真实的事件处理。第一个观察者是我自己的观察者。我想检查里面的一些条件,如果满足条件,我想阻止第二个观察者被调用。有没有办法实现这个目标?我尝试了Event.observe
和event.stop()
,但它没有我想要的效果。
return false