Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.62 KB | None | 0 0
  1. % calculations
  2. n = 20;
  3. ks = 1 : 20;
  4.  
  5. combs_byTA = 1 : n;
  6. combs_Matlab = 1 : n;
  7.  
  8. for k = 1 : 20
  9.     combs_byTA( k ) = nchoosek_byTA( n, k );
  10.     combs_Matlab( k ) = nchoosek( n, k );
  11. end
  12.  
  13. % are they equal? print result to screen
  14. if isequal( combs_byTA, combs_Matlab )
  15.     are_equal = 'equal';
  16. else
  17.     are_equal = 'not equal';
  18. end
  19.  
  20. fprintf( 'combs_byTA and combs_Matlab are: %s\n', are_equal );
  21.  
  22. % plot the two graphs for visual comparison: plot( x, y );
  23. subplot( 2, 1, 1 );
  24. plot( ks, combs_byTA );
  25. title( 'Plot of combs_byTA' );
  26.  
  27. subplot( 2, 1, 2 );
  28. plot( ks, combs_Matlab );
  29. title( 'Plot of combs_Matlab' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement