i have 72 node ( 1, ...,72 )
each node have a value between 0-1
i want calculate average each node become 1 cell
i know the coordinate (geometry ) of my cell and node
how to make it simple without manual input

댓글 수: 4

KSSV
KSSV 2019년 7월 12일
Use mean to get average. What you want is not clear from the file attached.
vaya putra
vaya putra 2019년 7월 12일
i have grid 5x5x1 so total cells 25 and node 72.
i coupling another simulation that he's output is in node
according to FVM cell center,
example
for cell no 1 have number of node 0 1 10 11 36 37 46 47
cell no 2 have number of node 1 2 9 10 37 38 45 46
assume each node has value
node 0 = 0.5
node 1 = 1
node 10 = 0.2 etc
so i can define value in cell center is (0.5+1+0.2+...)/8
KSSV
KSSV 2019년 7월 12일
You can use mean right?
vaya putra
vaya putra 2019년 7월 12일
for 25 cell its okay
but next i have 1000 cells, so its impossible if by manual input. this is using VTK Unstructurd grid

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2019년 7월 12일

0 개 추천

I got the problem..I think you want to do the following.
A = xlsread('NODETOSELL.csv') ; % read the file
node_vals = A(:,3) ; % node values
cells = A(:,7) ; % cells
nodes = A(:,8:15) ; % respective nodes in cells
% Remove the nans
cells(isnan(cells(:,1)),:) = [] ; % remove the nans in the cells (this is due to your file pattern)
nodes(isnan(nodes(:,1)),:) = [] ; % remove the nans in the cells (this is due to your file pattern)
% GEt the average
N = length(cells) ;
iwant = zeros(N,1) ;
for i = 1:N
iwant(i) = mean(node_vals(nodes(i,:)+1)) ; % i is added because, node has 0, and MATLAB index starts with 1
end

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

질문:

2019년 7월 12일

답변:

2019년 7월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by