Effacer les filtres
Effacer les filtres

illogical solution. How can i fix it?

2 vues (au cours des 30 derniers jours)
Physiker192
Physiker192 le 15 Août 2014
Modifié(e) : Star Strider le 15 Août 2014
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.

Réponses (0)

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by