Script runs, but can't see solution
古いコメントを表示
My code is shown below. I am trying to fit my data with an equation we developed. I get a plot at the end of the run with no errors, but all I see is the data curve, no fitting curve. What could be wrong here? I've attached the figure that is produced when running this script. The data is in blue, and the fitting curve should show up in red...VarName1 and VarName2 are the x and y data points I imported.
t = VarName1;
y = VarName2;
plot(x,y,'--b');
xlabel('Time');
ylabel('Current');
modelFun = @(p,t)(-167.*((1 - (p(2) ./ p(1).*(0.0001 - ((4 .* 0.0001 / 3.1415)) .* (exp(-((1/20) .*...
(3.1415^2) .* t ./ 1000))-(1/3) .* exp(-((9/20) .* (3.1415^2) .* t ./ 1000)...
)) / 3.1415))) .* exp(-((p(1) .* (0.0001 - ((4 .* 0.0001 / 3.1415) .* (exp(-((1/20) .* (3.1415^2)...
.* t ./ 1000))-(1/3) .* exp(-((9/20) .* (3.1415^2) .* t ./ 1000))) / 3.1415)...
)) + p(2)) .* t ./ 1000)+(p(2) ./ p(1) .* (0.0001 - ((4 .* 0.0001 / 3.1415) .* (exp(-((1/20).*...
(3.1415^2) .* t ./ 1000))-(1/3) .* exp(-((9/20) .* (3.1415^2) .* t / 1000)...
)) / 3.1415)) + p(2))));
startingVals = [-296 0.0573];
coefEsts = nlinfit(t, y ,modelFun, startingVals);
xgrid = linspace(0,20,100);
line(xgrid, modelFun(coefEsts, xgrid), 'Color', 'r');
1 件のコメント
Joseph Cheng
2017 年 4 月 5 日
what do you get when you just plot(xgrid, modelFun(coefEsts, xgrid), 'Color', 'r');
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!