Solving nonlinear equation inside for loop
古いコメントを表示
I want to solve for p in the following equation: a1*P^0.5+a2*p+a3*p^1.5=k
if I need to iterate K from 1 to 10000 this is the code:
a1=1.4*10^25;
a2=2.7*10^24;
a3=1.311*10^23;
k=linspace(1,10000,10000);
syms p
for i=1:10000
p(i)=solve((a1*p(i)^0.5)+(a2*p(i))+(a3*p(i)^1.5)==k(i))
end
however I get the following error: Index exceeds the number of array elements (1).
Thank you.
3 件のコメント
Kim Ibrahim
2021 年 11 月 23 日
Dyuman Joshi
2021 年 11 月 24 日
You are expecting 3 solutions for each p and k, right?
Kim Ibrahim
2021 年 11 月 30 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!