lsqnonlin function error confusion
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I was running this code and it was working well but when I made small modifications it stopped working. Any help or clarification is appreciated! See code and error below:
function [R] = optimize_radius (raw_EM_cath)
numcath = size(raw_EM_cath,2);
for i = 1:numcath
raw_EM_cath(i).cath = raw_EM_cath(i).cath(8:end,:);
center = lsqnonlin(@(point)distance(point, raw_EM_cath(i).cath), [median(raw_EM_cath(i).cath(:,1)), median(raw_EM_cath(i).cath(:,2)), median(raw_EM_cath(i).cath(:,3))]);
d = pdist2(center, raw_EM_cath(i).cath);
R(i, :) = [ mean(d), std(d), median(d), mode(d) ];
end
end
ERROR:
Output argument "d" (and maybe others) not assigned during call to
"optimize_radius>distance".
Error in optimize_radius>@(point)distance(point,raw_EM_cath(i).cath) (line 12)
center = lsqnonlin(@(point)distance(point, raw_EM_cath(i).cath),
[median(raw_EM_cath(i).cath(:,1)), median(raw_EM_cath(i).cath(:,2)),
median(raw_EM_cath(i).cath(:,3))]);
Error in lsqnonlin (line 196)
initVals.F = feval(funfcn{3},xCurrent,varargin{:});
Error in optimize_radius (line 12)
center = lsqnonlin(@(point)distance(point, raw_EM_cath(i).cath),
[median(raw_EM_cath(i).cath(:,1)), median(raw_EM_cath(i).cath(:,2)),
median(raw_EM_cath(i).cath(:,3))]);
Caused by:
Failure in initial objective function evaluation. LSQNONLIN cannot continue.
4 件のコメント
Walter Roberson
2017 年 9 月 20 日
There should not be a space between the dash and the "all". Not
which - all distance
But
which -all distance
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!