# illogical solution. How can i fix it?

조회 수: 3 (최근 30일)
Physiker192 2014년 8월 15일
편집: Star Strider 2014년 8월 15일
i have this code written to solve the system of equations saved in the array (dif) it does everything that i should do but the problem is that whenever i run my program i always get 0 as a solution.
n=input('n=');
E=input('E=');
h=3;
dif=sym(zeros(1,n));
F=0;
x=sym(zeros(1,n));
for k=1:n
x(k) = sym(sprintf('x%d',k));
end
for i=1:n
D= 0.5;
% V=0;
% b=0;
for j=1:n
if (mod(j,2)==0)
D = D + cos(h*x(j));
else
D = D - cos(h*x(j));
end
end
D=(2*E*sqrt(2)/(pi*h))*abs(D);
F = F + 1/h*(D^2);
h=h+2;
end
for j=1:n
dif(j)=diff(F,x(j),1);
end
S=double(solve(dif));
x = structfun(@subs,S)
can anybody tell me what's wrong with this code? thanks in advance.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

### 태그

아직 태그를 입력하지 않았습니다.

### Community Treasure Hunt

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

Start Hunting!

Translated by