%this is half part of the code which is not running because of this following error:
The following error occurred converting from sym to double:Error using mupadmexError in MuPAD command: DOUBLE cannot convert the input expression into a double array.If the input expression contains a symbolic variable, use the VPA function instead.Error in Galerkin (line 10) N(i)=(x.^2-2*x).^i;
This is my code:
syms pi p q E A l xn=3;k=(n:n);r=(1:n);a=(1:n);N=(1:n);pi=eval(pi);p=q*x/E*A*l;for i=1:n N(i)=(x.^2-2*x).^i; %Shape function
%N(i)=sin((2*i-1)/2*pi*x);
%N(i)=piecewise(x>=(i-1)/n & x<1/n+(i-1)/n,n*(x-(i-1)/n),x>=i/n & x<=(i+1)/n & x<1,-n*x+i+1,0);
Y1=(N(i)); Y2=diff(N(i),x); Y3=diff(N(i),x,2); x=linspace(0,1); plot(x,Y1) hold on plot(x,Y2) hold on plot(x,Y3) hold off Legend(N,N',N'');end
Best Answer