SHARE
TWEET

Untitled

a guest Oct 19th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. A1=0.6890;
  2. z=[0 10 20 30 40 50 60]; % Data points taken along z - axis (independent)
  3. d=[3.2 3.1 2.1 3.8*(1+A1) 4 4.5 3.9]; %[units:mm] meaured values of d at respective points along z
  4.  
  5. %=====================================================
  6. %Polynomial Interpolation (Lagrange)
  7. %=====================================================
  8.  
  9. syms z
  10. L=0;
  11. for ii=1:length(z)
  12.    Lj=1; % resets Lj to 1 for each iteration
  13.    for jj=1:length(z)
  14.        if ii~=jj %ends iteration when ii=jj
  15.            Lj=Lj*(z-z(jj))/(z(ii)-z(jj));%Formulating the Lj term using the lagrange equation
  16.        end
  17.    end
  18.    L=L + d(ii)*Lj;
  19. end
  20.  
  21. %=====================================================
  22. %Plot of Lagrange equation
  23. %=====================================================
  24.  
  25. ezplot(L, [0 60])
  26. xlabel('Surface Coordinate z (mm)')
  27. ax = gca;
  28. ax.FontWeight = ('bold');
  29. ylabel('Thickness d (mm)')
  30. title('Polynomial (Lagrange) Interpolation')
  31. hold on
  32. plot(z,d,'o')
  33. hold off
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top