I have the following parameters and function and I need to write a code solving for one variable.
Parameters:
Theta = 0.82
Alph= 0.27
D_x is a vector with 20 points (0-1.05)
The equation is
D_x= theta*x+(1-theta)* (x^(1-alpha))
I want to solve for x that corresponds to each point in D_x vector. Please let me know if you can help with this.
Thanks,
Cherin

 採用された回答

Star Strider
Star Strider 2021 年 3 月 9 日

0 投票

Try this:
theta = 0.82
alpha = 0.27
D_x = linspace(0, 1.05, 20);
D_x_fcn = @(x) theta*x+(1-theta).*(x.^(1-alpha));
for k = 1:numel(D_x)
xv(k) = fsolve(@(x) D_x(k) - D_x_fcn(x), 1);
end
Results = table(D_x(:), xv(:), 'VariableNames',{'D_x','x'})
producing:
D_x x
________ ________
0 0
0.055263 0.04469
0.11053 0.095319
0.16579 0.14781
0.22105 0.20143
0.27632 0.25583
0.33158 0.31083
0.38684 0.3663
0.44211 0.42218
0.49737 0.4784
0.55263 0.53491
0.60789 0.59168
0.66316 0.64868
0.71842 0.70589
0.77368 0.76329
0.82895 0.82086
0.88421 0.87859
0.93947 0.93646
0.99474 0.99447
1.05 1.0526
Note that fzero has problems with this, the reason I went with fsolve.

2 件のコメント

Cherin Hamadi
Cherin Hamadi 2021 年 3 月 10 日
This perfectly works. Thanks!
Star Strider
Star Strider 2021 年 3 月 10 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by