lsqnonlin function error confusion

1 回表示 (過去 30 日間)
Robert Smith
Robert Smith 2017 年 9 月 20 日
コメント済み: Robert Smith 2017 年 9 月 20 日
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
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
Robert Smith
Robert Smith 2017 年 9 月 20 日
Oh, forgive me. Here is the output:
distance is a Java method % java.awt.Point method distance is a Java method % java.awt.geom.Point2D method

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeJust for fun についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by