lsqnonlin function error confusion

1 vue (au cours des 30 derniers jours)
Robert Smith
Robert Smith le 20 Sep 2017
Commenté : Robert Smith le 20 Sep 2017
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 commentaires
Walter Roberson
Walter Roberson le 20 Sep 2017
There should not be a space between the dash and the "all". Not
which - all distance
But
which -all distance
Robert Smith
Robert Smith le 20 Sep 2017
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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Just for fun dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by