필터 지우기
필터 지우기

How to Graph integrals?

조회 수: 6 (최근 30일)
Researcher DSGE
Researcher DSGE 2024년 7월 27일
편집: Researcher DSGE 2024년 7월 29일
Hello everybody,
I'm trying to get this graph:
Using this code:
function res = fun(bs,gamma)
fun_ode = @(b,z)[(1-gamma)*z(1)/(z(2)-b);z(2)/(z(1)-b);z(1)];
z0=[1 1 0];
[B,Z] = ode45(fun_ode,[bs,0],z0);
res = bs - 0.5*(1+gamma*Z(end,3));
end
gamma = 0.3;
bs = 0.542
fun_ode = @(b,z)[(1-gamma)*z(1)/(z(2)-b);z(2)/(z(1)-b);z(1)];
z0=[1 1 0];
[B,Z] = ode45(fun_ode,[bs,0],z0);
hold on
plot(B,Z(:,1),'r')
plot(B,Z(:,2),'b')
hold off
grid on
Error using fplot>singleFplot (line 258)
Input must be a function or functions of a single variable.

Error in fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 218)
hObj = cellfun(@(f) singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);

Error in fplot>vectorizeFplot (line 218)
hObj = cellfun(@(f) singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);

Error in fplot (line 184)
hObj = vectorizeFplot(cax,fn,limits,extraOpts,args);
But I didn't get it. I would appreciate it if I could get the graph.

채택된 답변

Torsten
Torsten 2024년 7월 29일
편집: Torsten 2024년 7월 29일
According to proposition 4, the red curve should be the inverse bidding function X and the blue curve should be the inverse bidding function Y for the given value of gamma.
gamma = 0.3;
bs0 = 0.3;
bs = fsolve(@(b)fun(b,gamma),bs0,optimset('Display','None'))
bs = 0.4509
fun_ode = @(b,z)[(1-gamma)*z(1)/(z(2)-b);z(2)/(z(1)-b);z(1)];
z0=[1 1 0];
[B,Z] = ode45(fun_ode,[bs,0],z0);
hold on
plot(B,Z(:,1),'r')
plot(B,Z(:,2),'b')
hold off
grid on
function res = fun(bs,gamma)
fun_ode = @(b,z)[(1-gamma)*z(1)/(z(2)-b);z(2)/(z(1)-b);z(1)];
z0=[1 1 0];
[B,Z] = ode45(fun_ode,[bs,0],z0);
res = bs - 0.5*(1+gamma*Z(end,3));
end

추가 답변 (1개)

Walter Roberson
Walter Roberson 2024년 7월 27일
b is not defined.
This is the same problem as you had for your previous iteration of this question (which you have deleted.) I pointed out the problem there.
  댓글 수: 3
Walter Roberson
Walter Roberson 2024년 7월 29일
syms v a
gamma=0.3;
b_hat=0.542;
fun = v/2;
B(v) = int(fun, v, 0, a)
B(v) = 
fplot(B,[0 1])
Error using fplot>singleFplot (line 258)
Input must be a function or functions of a single variable.

Error in fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 218)
hObj = cellfun(@(f) singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);

Error in fplot>vectorizeFplot (line 218)
hObj = cellfun(@(f) singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);

Error in fplot (line 184)
hObj = vectorizeFplot(cax,fn,limits,extraOpts,args);
You are defining B to be a function of v. But you are integrating over v with definite integral bounds that are independent of v, so the result will be independent of v. As a result, B(v) is independent of v, and is instead dependent on the constant a
Torsten
Torsten 2024년 7월 29일
편집: Torsten 2024년 7월 29일
I don't understand the relation between your graphs and Proposition 4. What is v ? Why is b plotted as y-axis and not as x-axis for it seems to be the independent variable ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by