Not spotting where/how index exceeds number of array elements

조회 수: 2 (최근 30일)
Brian Taff
Brian Taff 2019년 12월 13일
댓글: Brian Taff 2019년 12월 21일
I'm trying to solve a Navier-Stokes setup in a cylindrical coordinate system and am bumping up against an array indexing challenge. Any help folks might be able to offer to straighten matters out would be most appreciated. I'm including my live editor content below.

채택된 답변

Vladimir Sovkov
Vladimir Sovkov 2019년 12월 14일
Is this what you want? Live script vesion is attached.
xmesh = linspace(0.01,0.05,5);
solinit = bvpinit(xmesh, @guess);
sol = bvp4c(@bvpfcn, @bcfcn, solinit);
plot(sol.x, sol.y, '-o')
function bound = bcfcn(ua,ub)
bound = [ua(1)-0.1, ub(1)];
end
function g = guess(r)
g = [1*(0.05-r)/(0.05-0.01), -1/(0.05-0.01)];
end
function dudr = bvpfcn(r,u)
dudr = [u(2), u(2)./r];
end
  댓글 수: 4
Vladimir Sovkov
Vladimir Sovkov 2019년 12월 20일
편집: Vladimir Sovkov 2019년 12월 20일
No prob.
I do not understand why you replace your initial equation by . It seems to me that must have been with the "plus" sign, and, consequently, dudr = [u(2), u(2)./r] in the program, isn't it? Otherwise, you are solving the equation .
Brian Taff
Brian Taff 2019년 12월 21일
You are correct, I had mistyped the original equation in the live editor's documentation. It should have been stated as u'' + u'/r = 0.
The downstream function calls do, in fact, solve this equation and the results were as intended.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by