Value of first derivative of Shape function at -1,0 and +1 using for loop?? Error using sym/diff (line 69) The second argument must be a variable or a nonnegative integer specifying the number of differentiations. Error in practise3 (line 29) N1=dif

%%Shape function for axial effect
N1epsn=0.5*epsn^2-0.5*epsn; (ERROR HERE)
N2epsn=-1*epsn^2+1;
N3epsn=0.5*epsn^2+0.5*epsn;
for epsn=-1:1:1
%%First Derivatives of Shape Function
N1=diff(N1epsn,epsn)
N2=diff(N2epsn,epsn)
N3=diff(N3epsn,epsn)
end

5 Comments

Stick to syms or numerical , stick to one don’t mix all the time!
What does diff(expression, -1) mean to you? Is that integration?
Which variable does the -1 designate, or how many derivatives should be taken?
Notice that you are inside a for loop that is changing the value of the second parameter to diff and that you start at -1 which is confusing us.

Sign in to comment.

 Accepted Answer

%%Shape function for axial effect
syms epsn
N1epsn=0.5*epsn^2-0.5*epsn;
N2epsn=-1*epsn^2+1;
N3epsn=0.5*epsn^2+0.5*epsn;
for epsn=-1:1:1
%%First Derivatives of Shape Function
N1=subs(diff(N1epsn),epsn) ;
N2=subs(diff(N2epsn),epsn) ;
N3=subs(diff(N3epsn),epsn) ;
end
You should use double to convert sym to double.

5 Comments

I have already commented in your previous question that..using symbolic tool box is not a good option to do FEM analysis. I have given you few references too.
Thanks a lot KSSV. Your feedbacks have been really helpful.
How to take the second derivative of N1epsn=0.5*epsn^2-0.5*epsn; N2epsn=-1*epsn^2+1; N3epsn=0.5*epsn^2+0.5*epsn; ??

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!