Not spotting where/how index exceeds number of array elements
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Brian Taff
am 13 Dez. 2019
Kommentiert: Brian Taff
am 21 Dez. 2019
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.
0 Kommentare
Akzeptierte Antwort
Vladimir Sovkov
am 14 Dez. 2019
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 Kommentare
Vladimir Sovkov
am 20 Dez. 2019
Bearbeitet: Vladimir Sovkov
am 20 Dez. 2019
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
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/256473/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/256474/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/256475/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/256477/image.png)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!