Solve function is unable to find an explicit solution

1 次查看(过去 30 天)
This is my code. It is not there entirely.It is almost like this.
clc;
% Read image
I=imread('03022017_subset.tif');
sigma0_VH=I(:,:,1);
sigma0_VV=I(:,:,2);
LIA=I(:,:,3); %Local Incidence angle
[m,n,p]= size(I);
er=sym('er',[m,n]); % declaring dielectric constant as symbolic variable matrix
o=ones(m,n);
L=4;
pow=10;
x=0;
s=0.5;
w=((pi.*(L.^(2)))./pow).*(exp(-(((L.^(2)).*((((2.244.*sind(LIA).*cosd(x))-(1.121997.*(sind(LIA)))).^2)+((2.244.*sind(LIA).*sind(x)).^2))))./(4.*pow)));
SIvv=symsum(Ivv,z,1,Inf);
eqsigmavv=sigma0_VV-((1.258877268./4.*pi).*(exp(-2.*1.258877268.*(s.^2).*((cosd(LIA)).^2))).*((abs(SIvv)).^2).*(w./factorial(pow)))==0;
dcvv=solve(eqsigmavv,er);
solve function of 'dcvv' returning an answer of 1 by empty. But it is not what expected to get. The value of eqsigmavv is very lengthy. It is showing truncated in display. And some variable 'r' which is never declared in the programe is also included in it.
  7 个评论
Walter Roberson
Walter Roberson 2018-7-3
I think I will need the .tif for testing.
You did not answer my questions about how you intend your floating point constants to be interpreted: do you intend them to be interpreted as implicit rationals in base 10, or do you intend them as implicit rationals in base 2 (which is how floating point is stored internally) ?
If you had the floating point constant 0.333333 in your code, would you intend that to represent the rational 1 divided by 3, or would you intend it to represent the rational 333333 divided by 1000000, or would you intend it to represent the rational 3002396749180579 divided by 9007199254740992 ? These choices matter when you are using solve(), since solve() asks for the exact solution, and it is a mistake to ask for the exact solution for an expression with vague input values.
Perhaps you should be using vpasolve()

请先登录,再进行评论。

回答(2 个)

Sandra Maria Cherian
This is the image.I want to represent 1/3 as 0.3333

Sandra Maria Cherian
编辑:Sandra Maria Cherian 2018-7-5
Image is unable to attach. Can you please try it with following matrix.
ter=sym('ter',[3,3]);
to=ones(3,3);
LIAT=37.760056,36.951263,36.990906;37.904781,37.156265,37.195721;38.194260,37.566406,37.605480];
tRv0=(to-sqrt(ter))./(to+sqrt(ter)); tFt=8*(tRv0.^2) .*((sind(LIAT)).^2).*((cosd(LIAT)+(sqrt(ter-(sind(LIAT)).^2)))./(cosd(LIAT).*(sqrt(ter-(sind(LIAT).^2)))));
tSt0=(abs(to+((8.*tRv0)./(tFt.*cosd(LIAT))))).^(-2);
% surface roughness spectra W(n)
L=4; pow=10; x=0; s=0.5;
tw=((pi.*(L.^(2)))./pow).*(exp(-(((L.^(2)).*((((2.244.*sind(LIAT).*cosd(x))-(1.121997.*(sind(LIAT)))).^2)+((2.244.*sind(LIAT).*sind(x)).^2))))./(4.*pow)));
% Equation for St syms tz; tStn=symsum(((((1.121997.*s.*cosd(LIAT)).^(2.*tz))./(factorial(tz))).*tw),tz,1,Inf);
tStd=symsum(((((1.121997.*s.*cosd(LIAT)).^(2.*tz))./(factorial(tz))).*(((abs((tFt)+(((2.^(pow+2)).*tRv0./((exp((1.121997.*s.*cosd(LIAT)).^(2))).*cosd(LIAT)))))).^(2)).*tw)),tz,1,Inf); tSt=(((abs(tFt)).^2).*tStn)./tStd;
tRv=(cosd(LIAT)-sqrt(ter-(sind(LIAT)).^2))./(cosd(LIAT)+sqrt(ter-(sind(LIAT)).^2)); tRtv=tRv+((tRv0-tRv).*(to-(tSt./tSt0)));
tfvv=2.*tRtv./cosd(LIAT);
tTv=to+tRtv; tTvm=to-tRtv; tsq=sqrt(ter-(sind(LIAT)).^2); tFvv=(((((sind(LIAT)).^2)./cosd(LIAT))-(tsq./ter)).*(tTv.^2))-(2.*((sind(LIAT)).^2).*((to./cosd(LIAT))+(to./tsq)).*tTv.*tTvm)+(((((sind(LIAT)).^2)./cosd(LIAT))+(ter.*(to+(sind(LIAT)).^2)./tsq)).*(tTvm.^2));
syms tz; tIvv=((2.*1.121997.*s.*cosd(LIAT)).^tz).*tfvv.*(exp(-1.*1.258877268.*(s.^2).*((cosd(LIAT)).^2)))+((1.121997.*s.*cosd(LIAT)).^tz).*tFvv; tSIvv=symsum(((abs(tIvv)).^2).*tw./factorial(tz),tz,1,10);
tsigma0_VV=[0.11262583,0.86308515,1.1438491;0.14032036,1.0475565,1.6186293;0.21424975,0.61734170,0.90188682];
teqsigmavv=((tsigma0_VV-((1.258877268./(4.*3.14159)).*(exp(-2.*1.258877268.*(s.^2).*((cosd(LIAT)).^2))).*(tSIvv)))==0);
tic tdcvv = vpasolve(teqsigmavv,ter);
toc
  13 个评论
Walter Roberson
Walter Roberson 2018-7-6
Slightly better (at least for my implementing function):
2.09709586957955585, 4.50416224972559576, 5.13972527850544925
2.23993701810814461, 4.92827672315921195, 6.09692340175298675
2.57220009290275931, 3.87915792241145541, 4.59424410673230277
I tested with the range 20 to 90 as bounds, and all of the entries except possibly the first two quickly pinned themselves against the 20 lower bound (it looked like one of the first two might perhaps have been marginally different than 20 for the minimum value under the circumstance that all of the other values were 20.)
With that code, there is no way that there is a solution with any of the components required to be as large as 20.
Sandra Maria Cherian
I finally solved it. The symbolic matrix ter is converted to a single symbolic variable and for finding tdcvv a for loop is constructed.Still the values are not the expected.Almost same as what you got. Now I am working on it.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by