suppose that each of the four edges of a thin metal plate is maintained at a constant temperature and that we wish to detrmine the steady state temperature at each interior point . to do this we divide the plate to squares the corners of which are called nodes. and find the temperature at each interior node by averaging the four neighboring temperatures that is if T(ij) denotes the old temp at the node in i ro and j coloumn.

the Eqn. is ( T(i-j) +T(ij-1) + T(ij+1) + T(i+j) )/4

< the i and j are the indexes>
we use a two deminsional array each array element represents the temp at each node
they want a program that reads the temps along the four edges , and use these values to initialize the array.
and then averaging the temp at each node from its four neighboirous then print the array elemnts.
plzzzzzzzzz sombody help me with this ASAP cuz it makes me mad as hell not be able to solve any problem cuz i dont understand the question.
thnx everybody fo ur responses =>

Answered by WaltP 2,905 in a post from

If you want to know how a program works, plzzzzzzzzzzzz post a program. Or try reading the Rules for the site.

Answered by vmanes 1,165 in a post from

What I believe the problem is asking you to do is set up the 2D array.

Read in the temperatures along the edges (is the temperature the same all along an edge or does it vary along the edge, particularly near the corners?)

Once the edges are initialized, …

All 5 Replies

plzzzzzzzzz guys any one can help me with understanding how this program works i will be soo gratfull... thnx

If you want to know how a program works, plzzzzzzzzzzzz post a program. Or try reading the Rules for the site.

What I believe the problem is asking you to do is set up the 2D array.

Read in the temperatures along the edges (is the temperature the same all along an edge or does it vary along the edge, particularly near the corners?)

Once the edges are initialized, begin processing the interior nodes. Your formula is a bit off, I think the array references should be more like

( T(i-1,j) +T(i,j-1) + T(i,j+1) + T(i+1,j) )/4

this visits the elements above, below, right and left of the current node at (i,j)

But a problem I see is that as you start out, say from the top left position, is that there is no current data in the nodes to the right and below. Does the assignment address the initial state of all nodes?

What I believe the problem is asking you to do is set up the 2D array.

yes that is one problem should i allocate a dynamic array with the new int
i tried ((( int *ptr = new [j] )))
but it genrated an error,,, or should I just make a 2-d regular array
array = 

Read in the temperatures along the edges (is the temperature the same all along an edge or does it vary along the edge, particularly near the corners?)

yes it is the same along the edges but it differs in the node

this visits the elements above, below, right and left of the current node at (i,j)

i think this is better i didnt understand the first one,, thnx

But a problem I see is that as you start out, say from the top left position, is that there is no current data in the nodes to the right and below. Does the assignment address the initial state of all nodes?

i dont know where to start first in the plate
and the assigment says i should write a program that reads the four temps alonge the edges and some guess of the temps at the iterior points and use these values to intilize the elments of the array with these values.\

if u can help with this program and maybe showing me how to write the for loop to get the results ill be grateful
-should i make any assumptions for the program on my own or it doesnt need any??!!

For your array, if the problem is given as a set size, just declare a local array, as you show int plate; for example.

If no specific info is given for initial state of interior nodes, you might consider assigning them the average of the edge temperatures - that at least puts them in the approximate range. Then assign the temperature values to the edge nodes.

For the evaluation step, simply run nested for loops that only visit the interior nodes. Using the array declaration above, something like

int r, c;
for( r = 1; r < 9; r++ )
for( c = 1; c < 9; c++ )
{
//process the node by averaging the up/down/left/right nodes
}

This row by row approach might be a bit simplistic, and tend to give more weight to the upper left temperature. Perhaps a better approach is to somehow spiral around the nodes, working from outer edges towards the center
Now your turn - write some code. Start simple, get some parts working and build upon them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.