How can I write a matlab code for the below mentioned expression?

조회 수: 2 (최근 30일)
Anomitra Saha
Anomitra Saha 2019년 7월 4일
편집: Basil C. 2019년 7월 4일
where
ne(a,b) = 0 for (a=b)
= 1 for (a not equal to b)
H(x) is the heavyside function
I have an 1D domain in x and is divided into no. of cells. and so on are the cell boundaries with i=1,2.......
is the representative point of the cell (here its the mid point of the cell)
Taking for example =5, how can I write the code in Matlab so that I get separate expressions for for i=1,2,3,4,5?

채택된 답변

Basil C.
Basil C. 2019년 7월 4일
편집: Basil C. 2019년 7월 4일
Hi Anomitra,
For the variable 'ne' you could define it as a Np x Np with diagonal elements as 0 and non diagonal elements as 1
ne= ne=ones(Np)-diag(ones(1,Np));
For H(x) you could you the function 'heaviside'
heaviside(x(j)+x(k)-xb(i))
Also to define B(i) you could use the for loop
B=zeros(1,Np)
for i=1:Np
for j=1:Np
for k=1:j
B(i)=B(i)+0.5*(1+ne(j,k))*heaviside(x(j)+x(k)+xb(i))-heaviside(x(j)+x(k)-xb(i))*(j+k)*N(j)*N(k);
end
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

제품


릴리스

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by