Back Home Up


exercices arrays


  1. Create a 2-D array, A, with 5 columns and 3 rows using the INDGEN function

  2. Print the array to the screen and verify its structure and contents

  3. Print TRANSPOSE(A). What are its characteristics?

  4. Print REVERSE(A). What are its characteristics?

  5. Now let B=[0,1,2]

  6. Predict, then verify, the outcome of the following operations:

  7. C = A+1

  8. C = A*0

  9. C = A^2

  10. C = A*(A+3)

  11. C = A/A

  12. C = EXP(A)

  13. C = A+B

  14. C = A*B

  15. C = A(*,2)*B

  16. C = A(4,2)*B

  17. C = A#B

  18. C = B#A

  19. C = B##A

  20. Now replace the element in A[3,1] with the value 100

  21. Verify the result by printing

  22. Type the following command and interpret the result:
    PRINT, WHERE(A EQ 100)

  23. Create Z, a 301x301 array, using the FINDGEN function.

  24. What are the maximum and minimum values of Z?

  25. Using internal subscript notation, print to the terminal:

  26. The first 50 elements of the first row of Z

  27. The first 50 elements of the 99th column of Z

  28. The last 10 elements of the 100th row of Z

  29. Use the AstUseLib (use add_path,/astro before) routine IMLIST to double-check the results of the preceding exercise for the last 10 elements of the 100th row of Z. To get information on the IMLIST routine, type MAN,'IMLIST. [Note: you will have to use the optional WIDTH keyword to increase the size of the printed display in order to read all digits in the Z entries.]

  30. Write an IDL expression which yields the contents of Z[I,J] as a function of I and J. [NOTE: remember the IDL subscripting convention for arrays is reversed from FORTRAN's: in IDL A[I,J] yields the value of the I-th column and J-th row.]

  31. Verify the expression against the actual contents of Z for selected locations.

  32. Now define B = FLTARR(101,101)+20000.

  33. What are the maximum and minimum values of B?

  34. Using internal subscript notation, set the 51st column of B equal to 100000.

  35. Then set the 51st row of B equal to 100000.

  36. Now insert the array B into the original array Z, with the lower left-hand corner of the insert beginning at Z[100,100].

  37. Confirm the placement of the insert using IMLIST




IDL courses C. Morisset 2004 IA/UNAM V 2.2

Back Home Up