daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. % double A_d = 0.32345;
  2. % double B_d = 0.78743;
  3. % double C_d = 0.56532;
  4. %
  5. % float A_f = 0.32345;
  6. % float B_f= 0.78743;
  7. % float C_d = 0.56532;
  8. close all;
  9. A=0.32345;
  10. B=-0.78743;
  11. C=0.56532;
  12. % A_bin=zeros(20);
  13. prec_f=18;
  14. for i = 1:prec_f
  15.     A_fix=fixed(A,1,1,i);
  16.     B_fix=fixed(B,1,1,i);
  17.     C_fix=fixed(C,1,1,i);
  18.     if i==7
  19.         A_bin=bin(A_fix);
  20.         B_bin=bin(B_fix);
  21.         C_bin=bin(C_fix);
  22.     end
  23.    
  24.     A_fix=double(A_fix);
  25.     B_fix=double(B_fix);
  26.     C_fix=double(C_fix);
  27.  
  28.     Y=(A+B)*C;
  29.     Y_fix=(A_fix+B_fix)*C_fix;
  30.  
  31.     error_res_y(i)=abs(Y-Y_fix);
  32.     error_res_a(i)=abs(A-A_fix);
  33.     error_res_b(i)=abs(B-B_fix);
  34.     error_res_c(i)=abs(C-C_fix);
  35. end
  36.  
  37. Y_fix=fixed(Y_fix,1,1,i);
  38. Y_bin=bin(Y_fix);
  39.  
  40. X=linspace(1,prec_f,prec_f);
  41. figure
  42. plot(X,error_res_y);
  43. grid on;
  44. xlabel('Ilośc bitów czesci ułamkowej');
  45. ylabel('Błąd bezwzględny');
  46. figure
  47. grid on;
  48. plot(X,error_res_a);
  49. xlabel('Ilośc bitów czesci ułamkowej');
  50. ylabel('Błąd bezwzględny');
  51. hold on;
  52. grid on;
  53. plot(X,error_res_b);
  54. plot(X,error_res_c);
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
 
Top