Solve an equation not getting a result
5 次查看(过去 30 天)
显示 更早的评论
Hey here is my code, I don't know why I am not getting an answer,
E=9*10^3; nu=0.3; k=0.01; G=2*10^3; evide0=0.8;increment1=0.0001;
e1=[0:increment1:1];
s01=0;
s1=[s01];s1(1)=s01;
for i=2:length(e1)
syms x
a=double(solve(increment1==((1/3)*(k/(1+evide0))*((x-s1(i-1))/x))+((1/3*G)*(x-s1(i-1)))),x);
s1(i)=a
if s1(i)>500
s1=s1(1:(i-1));
break
end
end
I am not getting a value in a
回答(2 个)
Catalytic
2022-2-12
>> solve(increment1==((1/3)*(k/(1+evide0))*((x-s1(i-1))/x))+((1/3*G)*(x-s1(i-1))) ,x)
ans =
-2.6278e-06
Star Strider
2022-2-12
The solve call was causing problems because the conversion and testing in the if block would then not work correctly because the logical test does not work for symbolic variables. Also, the ‘a’ result was frequently empty, and that effectively stopped the iteration. So I changed the call to fsolve (and made approprite changes to the code for the expression it was to solve) that elimnated those problems, and temporarily changed the value of ‘increment1’ to something reasonable that I could execute in the online Run feature here.
% syms x
E=9*10^3;
nu=0.3;
k=0.01;
G=2*10^3;
evide0=0.8;
increment1=0.0001;
increment1 = 0.01;
e1=[0:increment1:1];
s01=0;
% s1=[s01];
s1{1}=s01;
for i=2:length(e1)
% syms x
a = fsolve(@(x)increment1 - ((1/3)*k/(1+evide0)) * (x-s1{i-1})/x + ((1/3*G)*(x-s1{i-1})) ,(1+1i)*1000)
if isempty(a)
s1{i} = {0};
else
s1{i}=a;
end
if real(s1{i})>500
s1{i} = s1{1:(i-1)};
break
end
end
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -1.2222e-05 - 1.8158e-19i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -2.5762e-05 + 1.2116e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -3.9783e-05 + 3.8858e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -5.4050e-05 + 2.9737e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -6.8465e-05 + 2.2520e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -8.2979e-05 + 2.6854e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -9.7564e-05 + 2.3754e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -1.1220e-04 + 2.5388e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -1.2688e-04 + 2.6473e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -1.4159e-04 + 2.7222e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -1.5633e-04 + 2.7756e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -1.7109e-04 + 2.7273e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -1.8587e-04 + 2.7566e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -2.0066e-04 + 2.7299e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -2.1547e-04 + 2.7475e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -2.3029e-04 + 2.7318e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -2.4513e-04 + 2.7194e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -2.5997e-04 + 2.7286e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -2.7482e-04 + 2.7209e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -2.8968e-04 + 2.7272e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -3.0454e-04 + 2.7222e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -3.1941e-04 + 2.7180e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -3.3429e-04 + 2.7220e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -3.4917e-04 + 2.7192e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -3.6406e-04 + 2.7168e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -3.7895e-04 + 2.7194e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -3.9384e-04 + 2.7178e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -4.0874e-04 + 2.7164e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -4.2364e-04 + 2.7182e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -4.3855e-04 + 2.7198e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -4.5346e-04 + 2.7213e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -4.6837e-04 + 2.7226e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -4.8328e-04 + 2.7238e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -4.9820e-04 + 2.7233e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -5.1312e-04 + 2.7229e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -5.2804e-04 + 2.7238e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -5.4296e-04 + 2.7246e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -5.5789e-04 + 2.7244e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -5.7282e-04 + 2.7251e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -5.8775e-04 + 2.7249e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -6.0268e-04 + 2.7255e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -6.1761e-04 + 2.7261e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -6.3254e-04 + 2.7266e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -6.4748e-04 + 2.7271e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -6.6242e-04 + 2.7276e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -6.7736e-04 + 2.7275e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -6.9230e-04 + 2.7280e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -7.0724e-04 + 2.7283e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -7.2218e-04 + 2.7287e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -7.3712e-04 + 2.7290e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -7.5207e-04 + 2.7291e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -7.6701e-04 + 2.7291e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -7.8196e-04 + 2.7291e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -7.9691e-04 + 2.7294e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -8.1186e-04 + 2.7294e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -8.2681e-04 + 2.7294e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -8.4176e-04 + 2.7295e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -8.5671e-04 + 2.7297e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -8.7166e-04 + 2.7298e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -8.8662e-04 + 2.7300e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -9.0157e-04 + 2.7300e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -9.1652e-04 + 2.7302e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -9.3148e-04 + 2.7304e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -9.4644e-04 + 2.7306e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -9.6139e-04 + 2.7307e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -9.7635e-04 + 2.7309e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -9.9131e-04 + 2.7310e-14i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0010 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0010 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0010 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0011 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0011 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0011 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0011 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0011 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0011 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0011 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0012 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0012 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0012 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0012 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0012 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0012 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0012 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0013 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0013 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0013 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0013 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0013 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0013 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0014 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0014 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0014 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0014 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0014 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0014 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0014 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0015 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0015 + 0.0000i
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the value of the function tolerance, and
the problem appears regular as measured by the gradient.
a = -0.0015 + 0.0000i
figure
plot(e1, real([s1{:}]))
grid
xlabel('e_1')
ylabel('s_1')
This runs without error. Make appropriate changes if it does not produce the desired result.
.
2 个评论
rita richa
2022-2-12
thank you, I actually were searching for a positive real answer not an immaginary one but I found the problem, I had a mistake in the equation.
Thanks a lot for your time.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)