3d mesh and index operations

1 visualización (últimos 30 días)
gianluca
gianluca el 9 de Jul. de 2012
Hi, I've a 3d grid:
[X,Y,Z] = meshgrid(0:250:1000,0:250:1000,0:250:1000);
and a surface (in this example a plane):
[xi,yi] = meshgrid(0:250:1000,0:250:1000);
zi = xi .* 0.5 + yi .* 0.1;
To assign at each node a selected propriety (th) I write for the nodes above the surface
for i = 1:5
for j = 1:5
for k = 1:zi(i,j)
th(i,j,k) = 1.5
end
end
end
end for the nodes below the surface? Any suggestions are grateful.
gianluca
  2 comentarios
Mark Whirdy
Mark Whirdy el 9 de Jul. de 2012
Hi Gianluca
I think some of your question maybe got cut off - what is the issue with your code?
Can you explain what this means?: "To assign at each node a selected propriety (th) I write for the nodes above the surface"
Best Rgds, mark
gianluca
gianluca el 9 de Jul. de 2012
Hi mark, I'm building a 3d geological model (two layers). I would assign at each node of the model a physical property (e.g. thermal conductivity as I'm building a thermal model) taking into account the two different lithologies. The boundary between the bottom of the first layer and the top of the second one is defined by a surface (e.g. a plane). With this command I assign at each node above the depth zi a value of thermal conductivity th = 1.5
for i = 1:5
for j = 1:5
for k = 1:zi(i,j)
th(i,j,k) = 1.5
end
end
end
I would assign a different value at nodes below the depth zi, but I've not idea how write this command: for index k that varies from the depth zi to the bottom of the model, the thermal conductivity th = 2.5.

Iniciar sesión para comentar.

Respuesta aceptada

Mark Whirdy
Mark Whirdy el 9 de Jul. de 2012
Editada: Mark Whirdy el 9 de Jul. de 2012
To give this the best chance of being answered by someone in the community here, I think its a good idea to explain it without using any application-specific terminology (node, layer, conductivity, boundary, depth) and only talking about the variables, dimensions and indexes (i,j,k) and other matlab terms.
(Having a bit of guess at this ...) Assuming that your code snippet successfully assigns 1.5 to those elements of "th" that are "above the depth zi ", it seems that ALL of the remaining elements of "th" (having value 0) are then "at nodes below the depth zi" and you want to assign a "different value" to ALL of these (is this right??). Then you need only replace all zeros with your "different_value" (see snippet below)
If I've misinterpreted this, you'll need to help me out with a more generic application-independent explanation. Let me know
different_value = 2.5;
th(th==0) = different_value;

Más respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by