Lecture-24(arrays) - this number Lower bound now is 1 If...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Data Arrays
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Multi-Dimensional Arrays Arrays can be defined of up to 60 dimensions Engineering calculations frequently deal with 4 dimensional arrays (x,y,z, t) Supposing we want to compute the temperature at the nodes of the plate in o F and store it. Write a code. 10 m 10 m The temperature at a node is given by: 100 2 2 y x o e T + -
Image of page 2
Example This part of the code to size the grid Can you understand why the coordinates of the Cells is specified as such?
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Array’s Lower Bound The default lower bound of the array is 0 The lower bound can be changed by: If the lower bound of the arrays in all procedures in a module has to be a value other than zero Dim Temperature(10) as Single Dim Temperature(1 To 10) as Single Option Explicit Option Base 1 Sub Temperature Dim Temperature(10) as Single If the lower bound has to be different from 1 then change
Image of page 4
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: this number Lower bound now is 1 If you want to check the lower bound of an array use Lbound(arrayname, dimension) Lbound(y, 2) Passing Arrays to Procedures In the previous example of temperature at nodes of a plate, supposed we want to ultimately calculate and store temperature in o F. We also want to report the min. and max. temperature. Call conv(T(), nx, ny, Min, Max) Sub conv(T, nx, ny, Min, Max) Tells the program that T is going to be an array No parenthesis required here for T Tells the subroutine the size of the array Example Bubble Sort Example The basic idea is that one goes down an array comparing adjacent pairs and swapping values if they are out of order. We pass through the array many times until there are no more swaps. Can you write a code to implement the bubble sort logic?...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern