summation of aij & i, j dependent function in matlab

조회 수: 1 (최근 30일)
BenK
BenK 2024년 4월 22일
댓글: BenK 2024년 4월 22일
Hello, I am trying to create a code that can calculate the local resistance coefficient via formula above. the values of ai and aij are defined.
I have created a code using for loops, but getting a really high number.
I have defined example values for Re, f0, and f1 values below. Using the published graph, I should be getting around 1-1.1
ai and bi are values defined.
Please forgive me, it might be that I got matrix algebra incorrect, as I am thinking that might be the suspicion but not sure what I need to change at this point.
Thank you.
%
% initial contraction from flow, formula from diagram 4.10
%
%
%given test values
Re_0=60.46;
f0=1;
f1=2.7225;
%
ind=8;
acoeff=0;
ai=[-25.12458,18.5076,-170.4147,118.1949,-44.42141,9.09524,-.9244027,.03408265];
for i = 1:ind
acoeff=acoeff+ai(i)*log(Re_0)^i;
end
acoeff
acoeff = -1.6830e+03
bi=[1.07 1.22 2.933;.05 -.51668 .8333; 0 0 0];
iB=3;
jB=3;
count=0;
B_inner=0;
Bcoeff=0;
for i=1:iB
for j=1:jB
B_inner=B_inner+bi(i,j)*((f0/f1)^j);
end
Bcoeff=Bcoeff+B_inner*log(Re_0)^i;
end
Coeff_local=(acoeff*Bcoeff)*(1-f0/f1)
Coeff_local = -6.6410e+04

채택된 답변

VBBV
VBBV 2024년 4월 22일
편집: VBBV 2024년 4월 22일
%
% initial contraction from flow, formula from diagram 4.10
%
%
%given test values
Re_0=60.46;
f0=1;
f1=2.7225;
%
ind=8;
acoeff=0;
ai=[-25.12458,118.5076,-170.4147,118.1949,-44.42141,9.09524,-.9244027,.03408265];
for i = 0:ind-1
acoeff=acoeff+ai(i+1)*log(Re_0)^i;
end
acoeff
acoeff = -0.0814
bi=[1.07 1.22 2.933;.05 -.51668 .8333; 0 0 0];
iB=3;
jB=3;
count=0;
B_inner=0;
Bcoeff=0;
for i=0:iB-1
for j=0:jB-1
B_inner=B_inner+bi(i+1,j+1)*((f0/f1)^j);
end
Bcoeff=Bcoeff+B_inner*log(Re_0)^i;
end
Coeff_local=(acoeff*Bcoeff)*(1-f0/f1)
Coeff_local = -2.1331
  댓글 수: 8
VBBV
VBBV 2024년 4월 22일
편집: VBBV 2024년 4월 22일
@BenK that value is natural log to decimal log conversion factor. since acoeff and Bcoeff are computed separately involving log function it needs to be used twice
BenK
BenK 2024년 4월 22일
Thank you for helping me with this issue. I will mark this as resolved

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by