이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Solve an equation not getting a result
조회 수: 1 (최근 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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/892280/image.png)
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.
Star Strider
2022년 2월 12일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
참고 항목
카테고리
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 (한국어)