| 1 |
function plotdensity(filename, xsize, ysize) |
| 2 |
|
| 3 |
data_obj = importdata(filename, ' ', 2); %% we need to skip the first two lines |
| 4 |
density = data_obj.data; |
| 5 |
nodes = load('nodes.txt'); |
| 6 |
|
| 7 |
density = reshape(density, xsize, ysize); |
| 8 |
|
| 9 |
xnodes = reshape(nodes(:,1), xsize+1, ysize+1); |
| 10 |
ynodes = reshape(nodes(:,2), xsize+1, ysize+1); |
| 11 |
|
| 12 |
xmax = max(max(xnodes)); |
| 13 |
ymax = max(max(ynodes)); |
| 14 |
|
| 15 |
X = []; Y = []; D = []; |
| 16 |
for i = 1:xsize |
| 17 |
for j = 1:ysize |
| 18 |
x = xnodes(i:i+1,j:j+1); |
| 19 |
y = ynodes(i:i+1,j:j+1); |
| 20 |
x = x(:); |
| 21 |
y = y(:); |
| 22 |
x(3:4) = x(4:-1:3); |
| 23 |
d = density(i,j)^3; |
| 24 |
X = [X,x]; |
| 25 |
Y = [Y,y]; |
| 26 |
D = [D,d]; |
| 27 |
end |
| 28 |
end |
| 29 |
|
| 30 |
figure |
| 31 |
fill(X,Y,D) |
| 32 |
xlim([0,xmax]) |
| 33 |
ylim([0,ymax]) |
| 34 |
colorbar |
| 35 |
%view(2) |
| 36 |
axis('equal','tight'); |
| 37 |
colormap(flipud(bone)) |
| 38 |
|
| 39 |
%figure |
| 40 |
%imagesc(density.^3); |
| 41 |
%colorbar |
| 42 |
%colormap('bone') |
| 43 |
|
| 44 |
end |