equation solver solve()

8 ビュー (過去 30 日間)
Hasan canar
Hasan canar 2021 年 2 月 14 日
編集済み: Hasan canar 2021 年 2 月 16 日
Hi all,
I use eqn solver for solving non-linear equation. ı have an array with constants and for the value Vg = -5.24, soln must be Zero but I got an error:
Error using subsasgn
Subscripted assignment dimension mismatch.
Error in sym/privsubsasgn (line 997)
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
Error in sym/subsasgn (line 834)
C = privsubsasgn(L,R,inds{:});
Error in onebytwo (line 25)
Sol(i) = vpasolve(Vs == Vg(i) + 5.24 - 1.8996*(exp(-Vs/0.026)+ Vs/0.026 -1 + 8.65*10^-14*(exp(Vs/0.026) - Vs/0.026 -1))^0.5, Vs,
guess)
Also below -5.24 ( -5.2,-5.0 ... etc) code works fine but does not solve Vg with more than two values. For this ı got an error like ;
Error using subsasgn
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in sym/privsubsasgn (line 997)
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
Error in sym/subsasgn (line 834)
C = privsubsasgn(L,R,inds{:});
Error in onebytwo (line 22)
Sol(i) = vpasolve(Vs == Vg(i) + 5.24 - 1.8996*(exp(-Vs/0.026)+ Vs/0.026 -1 + 8.65*10^-14*(exp(Vs/0.026) - Vs/0.026 -1))^0.5, Vs,
guess)
Moreover, Code does not solve values of Vg above -5.24 (-5.4,-5.6 ... etc)
Here is my code.
clear all
syms Vs Vg
guess = 0.01;
Vg = [
-5.4
-5.24
-5.2
-5.0
-4.8
-4.6
-4.4
];
for i = 1:length(Vg)
Sol(i) = vpasolve(Vs == Vg(i) + 5.24 - 1.8996*(exp(-Vs/0.026)+ Vs/0.026 -1 + 8.65*10^-14*(exp(Vs/0.026) - Vs/0.026 -1))^0.5, Vs, guess)
if ~isempty(Sol); guess = Sol; end
end
Hope I can get help.
Thank you
Hasan

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 2 月 14 日
編集済み: Walter Roberson 2021 年 2 月 14 日
I clearly showed in https://www.mathworks.com/matlabcentral/answers/739187-eqn-solver-could-not-solve-my-specific-seqn#comment_1322742 how to deal with that problem of subscript mismatch, with the thissol approach and testing for empty before assigning into the array.
  12 件のコメント
Hasan canar
Hasan canar 2021 年 2 月 16 日
編集済み: Hasan canar 2021 年 2 月 16 日
@Walter Roberson I got an error with that code (I m using R2015a)
Undefined function 'lhs' for input arguments of type 'sym'.
Error in WalterRoberson (line 22)
eqn_sep = [real(lhs(eqn))==real(rhs(eqn)), imag(lhs(eqn)) == imag(rhs(eqn))];
I put 'lhs' to syms and got another one
Error using syms (line 97)
Not a valid variable name.
Error in WalterRoberson (line 1)
syms VsR VsI real 1hs
Hasan canar
Hasan canar 2021 年 2 月 16 日
編集済み: Hasan canar 2021 年 2 月 16 日
@Walter RobersonI need to find such a graph from that equation[1].
When Vg = 5.24 Vs has to be 0 ! This is strict and if not holds physics behind the problem will be devastated.
Also, negative values exist for the same equation with different numbers (Vg, 1.8996, etc are different) but it does not change the situation.
Also, up to now you may find what I got so far, obviously w/out negative Vs values;
It can be easily claimed that I have a same trend as the literature and my data stucks at Vg = -5.24.
[1] Novkovski, 2017.

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

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by