3d mesh and index operations
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Mark Whirdy
2012년 7월 9일
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
채택된 답변
Mark Whirdy
2012년 7월 9일
편집: Mark Whirdy
2012년 7월 9일
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;
댓글 수: 0
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!