CodeCodeCode

ENRG132: HW02 - hw02_mvector_name

Mar 30th, 2011
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.97 KB | None | 0 0
  1. % --- INPUTS ---
  2. %creates a row vector with idicated values
  3. row_vector = [32, 4, 81, exp(2.5), 63, cos(pi/3), 14.12]
  4.  
  5. %creats a column vector with values staring from 15 going to -25 by steps of -5
  6. column_vector = (15:-5:-25);
  7. %takes former vector and shifts values into a column
  8. column_vector = column_vector'
  9.  
  10. %creates a matrix "C" with the indicated values
  11. C = [2, 4, 6, 8, 10; 3, 6, 9, 12, 15; 7, 14, 21, 28, 35]
  12.  
  13. % --- CALCULATIONS ---
  14. %creates column vector "uc" using columns 1, 3, and 5 of matrix "C"
  15. uc = [C(:,1); C(:,3); C(:,5)]
  16. uc = uc'
  17.  
  18. % --- OUTPUTS ----
  19. %row_vector =
  20. %
  21. %  32.0000    4.0000   81.0000   12.1825   63.0000    0.5000   14.1200
  22. %
  23. %
  24. %column_vector =
  25. %
  26. %    15
  27. %    10
  28. %     5
  29. %     0
  30. %    -5
  31. %   -10
  32. %   -15
  33. %   -20
  34. %   -25
  35. %
  36. %
  37. %C =
  38. %
  39. %     2     4     6     8    10
  40. %     3     6     9    12    15
  41. %     7    14    21    28    35
  42. %
  43. %uc =
  44. %
  45. %     2
  46. %     3
  47. %     7
  48. %     6
  49. %     9
  50. %    21
  51. %    10
  52. %    15
  53. %    35
Advertisement
Add Comment
Please, Sign In to add comment