Hello,

Could you explain for me why I'm not getting the same answer from the following two codes??

`function whatswrong(x)x1= linspace(0,x);n=length(x1); uy = -5/6.*(sing2(x1,0,4)-sing2(x1,5,4))... + 15/6.*sing2(x1,8,3) + 75*sing2(x1,7,2)... + 57/6.*x1^3 - 238.25.*x1;plot(x1,uy,'--')xlabel('x1') ylabel('uy'), title('displacement versus distance')function check = sing2(x1,a,n) if x1 > a check = (x1 - a).^n; else check=0; end`

——————————————————————————————————

`function beam2(x)x1= linspace(0,x);n=length(x1);for i=1:n uy(i) = -5/6.*(sing(x1(i),0,4)-sing(x1(i),5,4)); uy(i) = uy(i) + 15/6.*sing(x1(i),8,3) + 75*sing(x1(i),7,2); uy(i) = uy(i) + 57/6.*x1(i)^3 - 238.25.*x1(i);endplot(x1,uy) function check = sing(x1,a,n) if x1 > a check = (x1 - a).^n; else check=0; end`

many many thanks,

## Best Answer