solving one unknown variable in an equation

double(image1);
double(image2);
double(image3);
B=image1/1;
C=(image2-B*0.2)/(exp(0.58/0.025);
V1=0.025*((image3-B)./C);
syms j0
eqn = ((0.616-V1)/(j0*exp(V1/0.025)-0.038))*(j0*exp(V1/0.025)-0.038) == 0.616-V1 ;
solj0 = solve(eqn,j0)
unable to get solution for j0.
image is 1024x1024 pixels.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 8 月 2 日
編集済み: Walter Roberson 2016 年 8 月 2 日

1 投票

First of all,
double(image1);
is a wasted operation. It takes the value of image1, creates the double precision equivalent, and then throws away the value (because it is not assigned to any variable and the semi-colon tells it not to print the result.)
Secondly, you build V1 as an array, but in the first term of eqn you have an expression involving the array V1 "/" an expression involving the array V1. The "/" operator is matrix division, essentially a least squared calculation. To be consistent with everything else you should be using the ./ operator instead of the / operator
Thirdly, in the first sub-expression of eqn, you have j0 in the denominator, and then you multiply that term by something involving j0. The denominator j0 and the numerator j0 cancel each other out, so your expression is left with no j0 at all, so it is not possible to solve for j0.
Fourthly, you are creating a matrix of equations. That is not "one unknown variable", that is (1024 * 1024) unknown variables.

7 件のコメント

pe tina
pe tina 2016 年 8 月 3 日
編集済み: Walter Roberson 2016 年 8 月 3 日
syms j0
eqn = (((V3appl-V3))./(j0.*exp(V3/VT)-jp)).*(j0*exp(V4/VT)-jp) == V4appl-V4 ;
solj0 = solve(eqn,j0)
still unable to solve j0. why?
Walter Roberson
Walter Roberson 2016 年 8 月 3 日
Please indicate which of those variables are matrices and which are scalars. I suspect, given the original code, that at least one of them is a matrix, in which case you would be asking what scalar was able to simultaneously satisfy a matrix of equations.
MATLAB never assumes that a symbolic name should stand in for a matrix of values. More strongly: MATLAB cannot use a symbolic name to stand in for a matrix of values. If you need to solve for a matrix of values then you have to pass in a matrix of symbol names. For example,
j0 = sym('j', size(V3));
which would end up with a lot of symbol names such as j1_1, j1_2, j3_5 and so on.
If you are doing algebraic matrix multiplication or matrix inversion or determinant or eigenvalues or the like, then that is not something you can avoid.
If you are doing strict element-by-element operations then use a tactic such as
syms V3app1_ V3_ j0_ VT_ jp_ V4_ V4appl_
eqn = (((V3appl_-V3_))./(j0_.*exp(V3_/VT_)-jp_)).*(j0_*exp(V4_/VT_)-jp_) == V4appl_-V4_ ;
j0sol = solve(eqn, j0_);
j0 = subs(j0sol, {V3app1_ V3_ VT_ jp_ V4_ V4appl_}, {V3app1 V3 VT jp V4 V4appl});
MATLAB is able to extend the symbolic scalar formula it would get back from solve() to vectorized matrix operations.
Walter Roberson
Walter Roberson 2016 年 8 月 4 日
j0d = double(j0);
image(j0d); %or imagesc
xlswrite('J.xlsx', num2cell(j0d))
shoba
shoba 2016 年 8 月 4 日
pic1 = double (Pic1);
pic2 = double(Pic2);
pic3 = double(Pic3);
pic4 = double(Pic4);
ILB = 1;
B = pic1./ILB;
ILC = 0.2;
VC(1:1024,1:1024)= 0.581695;
VT = 0.025;
C = (pic2 - B*ILC)./(exp(VC./VT))
IL = 1;
V1 = VT*log((pic3 - B*IL)./(C));
V2 = VT*log((pic4 - B*IL)./(C));
Vapp1(1:1024,1:1024)=0.616185;
Vapp2(1:1024,1:1024)=0.575044;
jp = 0.038;
R =(((Vapp2-V2).*exp(V1./VT))-((Vapp1-V1).*exp(V2./VT)))./(jp.*(exp(V2./VT)-exp(V1./VT)))
imagesc(R);
syms V3app1_ V3_ j0_ VT_ jp_ V4_ V4appl_
eqn = (((V3appl_-V3_))./(j0_.*exp(V3_/VT_)-jp_)).*(j0_*exp(V4_/VT_)-jp_) == V4appl_-V4_ ;
j0sol = solve(eqn, j0_);
j0 = subs(j0sol, {V3app1_ V3_ VT_ jp_ V4_ V4appl_}, {V3app1 V3 VT jp V4 V4appl});
pic1,2,3,4 are 1024 x 1024. But when I run the coding to solve the j0; the status shows "Busy" and seems to not stop.How to solve this problem?
and even when I add the coding for j0d=.... to display the image. The status still shows "Busy".How to solve?
And how could I display both the images for R and J0 in the same figure? PLs help me edit my coding!
Walter Roberson
Walter Roberson 2016 年 8 月 4 日
Your pic3 - B*IL and pic4 - B*IL can end up negative, so the log() can end up complex. You cannot imagesc() complex data.
shoba
shoba 2016 年 8 月 4 日
Hi Walter, When I export the values for V1 and V2 with log(); the values are isn't complex. Then, why I'm not able to display the image for J0? Any solution?
Walter Roberson
Walter Roberson 2016 年 8 月 4 日
V3app1 and V4appl are not defined in your code and so cannot be subs() in to create j0.
Also be careful about the difference between 1 (the digit) and l (lower-case L) as you syms V3app1_ (with the digit) but your equation uses V3appl_ (with the lower-case L)

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

カテゴリ

質問済み:

2016 年 8 月 2 日

コメント済み:

2016 年 8 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by