Temperature distribution contour plotting
2 views (last 30 days)
Show older comments
Here is my task:
A 2D rectangle is heated on one corner and cooled on the other. Create a map of the temperature contours.
Here is my coding to create my grid:
% Defining initial variables
plate_length=60;
plate_height=40;
dx=10;
dy=10;
x = 0:dx:plate_length;
y = 0:dy:plate_height;
nx = length(x); ny = length(y);
%create arrays in y and x
[x_arr, y_arr] = meshgrid(x, y)
%creates array for temperature based on meshgrid size
temp = zeros(ny, nx)
Following this, I have defined the areas of the rectangle that are heated or cooled:
%defining heated points and their temperature
heated_length=20;
heated_top = find((y_arr == 0) & (x_arr <= heated_length));
heated_height=20;
heated_left = find((y_arr <= plate_height-heated_height) & (x_arr == 0));
heated_points = union(heated_top, heated_left);
heated_temp= 100;
temp(heated_points) = heated_temp
%defining cooled points and their temperature
cooled_length=10;
cooled_bottom = find((y_arr == 40) & (x_arr >= plate_length - cooled_length)) ;
cooled_height=10;
cooled_right = find((y_arr >= plate_height - cooled_height) & (x_arr == 60 ));
cooled_points = union(cooled_bottom, cooled_right) ;
cooled_temp= 0;
temp(cooled_points) = cooled_temp
This successfully gives me an array with the correct temperatures on each corner.
Now I must select all of the values in the temp matrix that are not part of the cooled or heated points. How can I do this? My heated points and cooled point are all defined, so how can I say (in code), 'for any point in the temp matrix that isn't a heated or cooled point, it must be set to a set value?'
Thanks Lewis
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!