How to Graph integrals?

8 visualizaciones (últimos 30 días)
Researcher DSGE
Researcher DSGE el 27 de Jul. de 2024
Editada: Researcher DSGE el 29 de Jul. de 2024
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.

Respuesta aceptada

Torsten
Torsten el 29 de Jul. de 2024
Editada: Torsten el 29 de Jul. de 2024
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

Más respuestas (1)

Walter Roberson
Walter Roberson el 27 de Jul. de 2024
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 comentarios
Walter Roberson
Walter Roberson el 29 de Jul. de 2024
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 el 29 de Jul. de 2024
Editada: Torsten el 29 de Jul. de 2024
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 ?

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by