이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I was trying to do fit with a script generated from cftool. It puts lower limit of 0 on all coefficients and the result returned is still negative. I would like to share the dataset but I am new to this forum and I don't find any option of sharing file. Please help me.
채택된 답변
Amol
2011년 2월 3일
0 votes Edit Delete Amol answered less than a minute ago
ok here is the script
function [cf_,gof]=myfit(tau,avar,weight)
%MYFIT Create plot of datasets and fits
% MYFIT(TAU,AVAR,WEIGHT)
% Creates a plot, similar to the plot in the main curve fitting
% window, using the data that you provide as input. You can
% apply this function to the same data you used with cftool
% or with different data. You may want to edit the function to
% customize the code and this help message.
%
% Number of datasets: 1
% Number of fits: 1
% Data from dataset "avar vs. tau with weight":
% X = tau:
% Y = avar:
% Weights = weight:
%
% This function was automatically generated on 04-Nov-2009 17:20:51
% --- Create fit "fit 1"
fo_ = fitoptions('method','LinearLeastSquares','Lower',[0 0 0 0 0]);
ok_ = isfinite(tau) & isfinite(avar) & isfinite(weight);
set(fo_,'Weight',weight(ok_));
if ~all( ok_ )
warning( 'GenerateMFile:IgnoringNansAndInfs', ...
'Ignoring NaNs and Infs in data' );
end
ft_ = fittype({'1/(x^2)', '1/x', 'x', 'x^2', '1'},...
'dependent',{'y'},'independent',{'x'},...
'coefficients',{'a', 'b', 'd', 'e', 'c'});
% Fit this model using new data
[cf_,gof] = fit(tau(ok_),avar(ok_),ft_,fo_);
% Or use coefficients from the original fit:
%if 0
% cv_ = { 2.8012463154944958529e-09, 4.1224210467149593554e-06, -6.2806159338057854499e-10, 1.1525415994665557154e-11, 5.4419882197796621562e-07};
% cf_ = cfit(ft_,cv_{:});
end
and yes I am sorry for a late response. I seems that i need to turn on some option to get email notification from the forum
댓글 수: 7
By the way, at present the forum does not generate email notifications. There is some support, though, for RSS feeds.
What magnitude of data are you passing in to be fitted? Looking at those coefficients in the comment, it does not appear to me that your fit is numerically stable.
the x data spans from 10e-2 to 10e6
y data sans from 10-3 to 10
(1E6)^2 = 1E12
1/(1E6)^2 = 1E-12
You are thus attempting to form systems with a range of 1E24, which is more than can be worked with in binary floating point numbers -- the maximum range is about 1E16.
Therefore you cannot expect to be able to fit your data without calculations that might take some coefficients negative due to round-off error.
is it true unconditionally?
It is unconditionally true that IEEE Double Precision Binary Floating Point numbers have 53 bits of precision, which is a dynamic range of about 1E-16.
If you need greater precision, then you need to either use the Symbolic Toolbox, or the Fixed Point Toolbox, or the Matlab File Exchange contribution for Variable Precision calculations, vpi . Note though that the functions you are wanting to use are probably not defined with any of these kinds of numeric representation.
thanks
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
