illogical solution. How can i fix it?
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!