Please ask the code
1 次查看(过去 30 天)
显示 更早的评论
回答(1 个)
Jan
2022-10-22
You overwrite the value of m multiple times:
m=3;
m=0.1;
m = linspace(0,0.001);
Because projfun is a nested function, it uses the last definition and the expression on the right hand side has 100 elements due to using the vector created by linspace.
This is a fragile code. The editor shows several problems already, so take the time to fix them.
Omit the clear command on top of a function, because it is just a waste of time there. This brute clearing header clc;clf;clear; is called "cargo cult programming".
for i = 1:numel(rr)
n=3; % Never used
...
i=i+1; % Why? This is not the way FOR loops work
end
If you share variables with nested functions, make it crystal clear using comments, which variables are concerned.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Boundary Value Problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!