function doesn't take number from main function
이전 댓글 표시
error: ??? Error using ==> sym.sym>notimplemented at 2621 Function 'lt' is not implemented for MuPAD symbolic objects.
Error in ==> sym.sym>sym.lt at 812 notimplemented('lt');
Error in ==> solverNRlinear at 19 if lt(norm_funkcije,tol)
Error in ==> glavnapokusaj at 79 [Sol]=solverNRlinear(initSol, epsp_novo1(i-1), epsp_novo2(i-1), epsp_novo12(i-1), alpha(i-1), epstotal1(i), epstotal2(i), epstotal12(i), K, lam, mi, sigmay);
I know that error stands for sym variable in solver NRlinear function, but in main function a set number for that syms:
else
initSol=[sigma_kon1(i-1) sigma_kon2(i-1) sigma_kon12(i-1) epsp_novo1(i-1) epsp_novo2(i-1) epsp_novo12(i-1) alpha(i-1) 0]
[Sol]=solverNRlinear(initSol, epsp_novo1(i-1), epsp_novo2(i-1), epsp_novo12(i-1), alpha(i-1), epstotal1(i), epstotal2(i), epstotal12(i), K, lam, mi, sigmay);
solverNR linear: function[Sol]=solverNRlinear(initSol, epspn1, epspn2, epspn12, alfan, eps1, eps2, epsp_novo12, K, lam, mi, sigmay)
Maxiter=100; tol=10e-6;
for iter=0:Maxiter
[fjacobian,InvJac]=linearfun(initSol, epspn1, epspn2, epspn12, alfan, eps1, eps2, epsp_novo12, K, lam, mi, sigmay);
delX=-InvJac*fjacobian
X=initSol+delX'
In linearfun I set (because of derivation):
syms sigma1 sigma2 sigma12 devsigma1 devsigma2 devsigma12 eps1 eps2 eps12 epsp1 epsp2 epsp12 epspn1 epspn2 epspn12 lambda alfa alfan
So solverNRlinear function only works with sym and don't want to use values from main function.
댓글 수: 4
Stephen23
2018년 4월 17일
Ivan Labetic
2018년 4월 17일
편집: dpb
2018년 4월 17일
Walter Roberson
2018년 4월 17일
Please show the complete code for the function that is failing.
답변 (1개)
Walter Roberson
2018년 4월 17일
function [f]=fun2(z, x, y) z1=z(1) z2=z(2) syms x y z1 z2 f=x^2+y+z1+z2 end
Your call to syms is the same as if you had done
x = sym('x') ;
y = sym('y') ;
z1 = sym('z1') ;
z2 = sym('z2') ;
And like all other assignments this overwrites the previous value of the variables. You are replacing all of your inputs with sym variables, discarding any numeric inputs.
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!