lsqcurvefit
조회 수: 7 (최근 30일)
이전 댓글 표시
Would LSQCURVEFIT work with comparing two complex functions? It looks like the metric for success is min sum {(FUN(X,XDATA)-YDATA).^2}, where it should be min sum {abs(FUN(X,XDATA)-YDATA).^2)} for complex-valued functions, or maybe sum {(FUN(X,XDATA)-YDATA).conj((FUN(X,XDATA)-YDATA))} Thanks Matt
댓글 수: 0
채택된 답변
Andrew Newell
2011년 3월 3일
Since the distance between two complex numbers a+i*b and c+i*d is (a-c)^2 + (b-d)^2, you could treat each complex number as a pair of independent real numbers. Wrap fun in a function rfun that returns the real and complex parts of the output. For example, assuming rfun returns a column vector,
function y = rfun(x)
y = rfun(x);
y = [real(y); imag(y)];
end
Similarly, you could replace ydata by
rdata = [real(ydata); imag(ydata)].
Then you have the first two inputs for lsqcurvefit.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!