How to solve non linear equation for one variable?

Hi, I am trying to solve a non-linear equation for one variable but it's not working. Can somebody help me in this regards? your help would be highly appreciated. Thanks
if
temp=[24 78 139 194 297 397];
yieldstress=[45 36 37 33 30 28];
syms DD positive
solve((6.046.*sqrt(DD))./(1e6)+(9.79.*(1-((-4.7872e-5.*temp).*(log(6.667e-4./(286.*sqrt(DD))))).^(2/3)).^(3/2)).*(3.06) == yieldstress);
end

 採用された回答

njj1
njj1 2018 年 4 月 24 日
編集済み: njj1 2018 年 4 月 24 日

1 投票

If you want to solve for multiple values of temp and yieldstress, you will have to use a for loop.
for i=1:numel(temp)
for j=1:numel(yieldstress)
out{i,j} = solve((6.046.*sqrt(DD))./(1e6)+(9.79.*(1-((-4.7872e-5.*temp(i)).*(log(6.667e-4./(286.*sqrt(DD))))).^(2/3)).^(3/2)).*(3.06) == yieldstress(j));
end
end
The output variable "out" contains the values of DD that solve the equations as symbolic numbers (so long as the equation can be solved), and these can be evaluated using the command eval().

3 件のコメント

Farhan Ashraf
Farhan Ashraf 2018 年 4 月 24 日
Now, Matlab is giving an error, specify a variable for which you solve. I introduce DD at the end of out{i,j} command. still same error is coming
njj1
njj1 2018 年 4 月 24 日

If you type in the code exactly as I have then it should work. It will take a while but it should work.

for i=1:numel(temp)
  for j=1:numel(yieldstress)
    out{i,j} = solve((6.046.*sqrt(DD))./(1e6)+(9.79.*(1-((-4.7872e-5.*temp(i)).*(log(6.667e-4./(286.*sqrt(DD))))).^(2/3)).^(3/2)).*(3.06) == yieldstress(j));
    dd(i,j) = eval(out{i,j}); %DO NOT put DD here
  end
end

FYI, I've run this code for the first few values of temp and yieldstress that you posted above, and Matlab is not able to find an explicit solution.

Farhan Ashraf
Farhan Ashraf 2018 年 4 月 24 日
what this error mean: A null assignment can have only one non-colon index? can you please guide?

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

その他の回答 (1 件)

Torsten
Torsten 2018 年 4 月 24 日

0 投票

The left-hand side of your equation (6.046.*sqrt(...)...) is a scalar, the right-hand side (yieldstress) is a vector. This is not compatible.
Best wishes
Torsten.

1 件のコメント

Farhan Ashraf
Farhan Ashraf 2018 年 4 月 24 日
Actually I want to calculate DD for each value of yieldstress and temp. Can you please suggest me something?

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

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

質問済み:

2018 年 4 月 24 日

コメント済み:

2018 年 4 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by