How to Graph integrals?

8 次查看(过去 30 天)
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