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 Comments

The problem is - how to get function f with values z1=4, z2=8,no the sym z1,z4 in following :
x=2
y=8
z(1)=4
z(2)=6
z=subs(z)
[f1]=fun1(z, x, y)
z=subs(z)
f1=subs(f1)
answer is: f1 = z1 + z2 + 17
I want to be z1,z2 the values.
-------
function [f]=fun2(z, x, y)
z1=z(1)
z2=z(2)
syms x y z1 z2
f=x^2+y+z1+z2
end
Please show the complete code for the function that is failing.
Sorry on little bit messy code.
Easily fixed:
  • Click on the pencil button above your post to enter edit mode
  • Select all the code
  • With the code still selected, click on the {} Code button
  • Press Submit

Sign in to comment.

Answers (1)

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.

Tags

Asked:

on 17 Apr 2018

Edited:

on 17 Apr 2018

Community Treasure Hunt

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

Start Hunting!