equation solver solve()
조회 수: 9 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



