Advertisement
AnttiLehikoinen

Reluctivity splines

Apr 22nd, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.58 KB | None | 0 0
  1. figure(3); clf; hold on; box on;
  2. B = BH(:,1); H = BH(:,2);
  3. v = H ./ B; v(1) = v(2); %calculate reluctivity; get rid of the v(1) = NaN
  4. plot(B.^2, v, 'ro'); %plot reluctivity w.r.t B^2
  5.  
  6. pp2 = spline(B.^2, v); %spline interpolation w.r.t. B^2
  7. B2 = linspace(0, 10, 1000); %for plotting
  8. plot(B2, ppval(pp2, B2), 'b') %plotting interpolated values
  9.  
  10. figure(4); clf; hold on;
  11. ppder2 = derivate_pp(pp2); %derivative of spline: dv / dB^2
  12. plot(B2, ppval(ppder2, B2), 'b') %plotting derivative of spline
  13. plot(B(2:end).^2, diff(v)./diff(B.^2), 'ro'); %plotting direct numerical derivative dv / dB^2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement