I continually am getting the same error messages for a bvp4c problem. I am using exactly the format from a Matlab provided example:
I saved these functions:
function dfdeta = fsode(eta,f)
dfdeta = [ f(2)
f(3)
-f(1)*f(3) - 1*(1 - f(2)^2) ];
end
function res = fsbc (f0,finf)
res = [f0(1)
f0(2)
finf(2) -1];
end
Then tried to apply:
infinity = 3;
maxinfinity = 6;
solinit = bvpinit(linspace(0,infinity,5),[0 0 1]);
sol=bvp4c(@fsode,@fsbc,solinit);
I get the follow error messages:

댓글 수: 1

Jan
Jan 2021년 3월 20일
If you post the text as text and not as screenshot, the readers can use it by copy&paste to create an answer.

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

답변 (1개)

Jan
Jan 2021년 3월 20일
편집: Jan 2021년 3월 20일

0 개 추천

res = [f0(1)
f0(2)
finf(2) -1]
The 1st and 2nd row contain 1 element, the 3rd row contains 2 elements. Be careful with the smart methods of Matlab, which allows you to omit commans and semicolons. The unary minus has no space on the right side, but the minus operator has one, if there is a space on the left. Tricky!
[1 2] % [1, 2]
[1 -2] % [1, -2]
[1 - 2] % [-1] !!!
Although it is convenient to omit the commas and semicolons, this is very susceptible for the distribution of spaces and therefore a bad programming style. I strongly recommend to write clean and clear code and not to use the lazy omitting. Use spaces around operators and omit the space on the right only for the unary minus operator:
res = [f0(1); ...
f0(2); ...
finf(2) - 1];
% ^ a space

카테고리

제품

릴리스

R2020a

태그

질문:

2021년 3월 20일

편집:

Jan
2021년 3월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by