For loop with constraint as a function

4 vues (au cours des 30 derniers jours)
Mo
Mo le 6 Sep 2012
Hi,
Here is my code :
%Parameters%
a=1.5;
gamma=0.5
lambda=0.07
r=0.0025
q=0.01
z=0.3
p=0.45
dc=0.4 ;
de=0.5 ;
alphae=0.20 ;
alphac=0.15;
ratio1=(lambda*gamma*(1-p))/(r+q)
ratio2=(lambda*gamma*p)/(r+q);
upperlimity1=a;
upperlimity2=a;
y1bar1=z;
y2bar1=z;
y1bar2=z+de*(1+ratio1*(1-alphae));
y2bar2=z+dc*(1+ratio2*(1-alphae)*(1-alphac));
% Values%
syms y1 y2
D=(z+ratio1*(1-alphae)*y1)/(1+ratio1*(1-alphae));
E= (z+ratio2*(1-alphae)*(1-alphac)*y2)/(1+ratio2*(1-alphae)*(1-alphac));
F= (z+ratio2*(1-alphae)*(1-alphac)*y2bar2+ratio2*(1-alphae)*alphac*(y2bar2-dc))/(1+ratio2*(1-alphae)*(1-alphac)+ratio2*(1-alphae)*alphac);
%%Function - Red line%%
redline =solve(D==E, y2);
pointB=solve(F== D, y1);
%%Figure
y2=0:0.01:a;
plot(y1bar1,y2,'k-');
hold on
y2=0:0.01:a;
plot(y1bar2,y2,'k-');
hold on
y1=0:0.01:a;
plot(y1,y2bar1,'k-');
hold on
y1=0:0.01:a;
plot(y1,y2bar2,'k-');
hold on
xlabel('Y1'); ylabel('Y2')
y1=z:0.01:a ;
y2=z:0.01:a;
redline = matlabFunction( redline );
y1=y1bar1:0.01:pointB;
y2=y2bar1:0.01:y2bar2;
plot(y1 , redline(y1),'r-');
hold on
I have a black rectangle in the center of the figure. I want to compute an integral A for values of Y1 and Y2 on the right side of the red line Y2=f(Y1) and an integral B for values of Y1 and Y2 on the left side of the red line.
for y1=y1bar1: y1bar2;
for y2=y2bar1: y2bar2;
I cannot write :
for y2 > f(y1) % since y2=f(y1)
How can I manage to do that ? Thanks a lot, Mo

Réponses (0)

Catégories

En savoir plus sur Error Functions dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by