Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.38 KB | None | 0 0
  1. clc;
  2. clear all;
  3. close all;
  4.  
  5. X=[exp(1), -pi, sqrt(2), -psi(1), log10(2)];
  6. Y=[1486.2497, 878366.9879, -22.37492, 4773714.647, 0.000185049];
  7.  
  8. s=0;
  9. for i=1:length(X)
  10.     s = s + X(i)*Y(i);
  11. end
  12.  
  13. s1=0;
  14.  
  15. for i=length(X):-1:1
  16.     s1 = s1 + X(i)*Y(i);
  17. end
  18.  
  19. s2 = dot(X,Y);
  20.  
  21. s3 = X(2)*Y(2) + X(4)*Y(4) + X(1)*Y(1) + X(3)*Y(3) + X(5)*Y(5);
  22.  
  23. disp(s);
  24. disp(s1);
  25. disp(s2);
  26. disp(s3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement