Lecture-24(arrays)

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

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

Data Arrays

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

View Full Document
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 + -
Example This part of the code to size the grid Can you understand why the coordinates of the Cells is specified as such?

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

View Full Document
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

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

View Full Document
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

## This note was uploaded on 04/27/2008 for the course PGE 310f taught by Professor Srinivasan during the Spring '08 term at University of Texas.

### Page1 / 7

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

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online