Data fitting using least square method, Please help me debug the errors.
古いコメントを表示
function F=goal(x,VGS,VDS,IDS) IpkoT=x(1) P1=x(2) alpha_r=x(3) lambda=x(4) P2=x(5) P3=x(6) alpha_s=x(7) phi=P1.*(VGS-Vpk)+P2.*(VGS-Vpk).^2+P3*(VGS-Vpk).^3 alpha=alpha_r+alpha_s*(1+tanh(Phi)) Vpk=-2.35 F=sum(IDS-(IpkoT.*(1+tanh(phi)).*tanh(alpha.*VDS).*(1+lambda.*VDS))).^2;
lc; global VGS global VDS global IDS error=@(x)goal(x,VGS,VDS,IDS) xtheta=[0.06 0.2 0.0019 0.128 0 0 0.1289] [bestx,fval]=fminsearch(error,xtheta) %% quality of fit IpkoT=bestx(1) P1=bestx(2) alpha_r=bestx(3) lambda=bestx(4) P2=bestx(5) P3=bestx(6) alpha_s=bestx(7) alpha=alpha_r+alpha_s*(1+tanh(Phi)) Vpk=-2.35 for i=1:360 phi=P1*(VGS(i)-Vpk)+P2*(VGS(I)-Vpk).^2+P3*(VGS(i)-Vpk).^3 I_fit=IpkoT.*(1+tanh(phi)).*tanh(alpha.*VDS(i)).*(1+lambda.*VDS(i)) scatter(VDS(i),I_fit','filled') hold on end for i=1:61 plot(VDS(i:61:length(VDS)),IDS(i:61:length(IDS))) hold on end
2 件のコメント
njj1
2018 年 4 月 18 日
It's going to make our jobs much easier if you type this code out in a more readable fashion. As it stands, it's very difficult to read and understand, which makes problem solving challenging.
John D'Errico
2018 年 4 月 18 日
編集済み: John D'Errico
2018 年 4 月 18 日
https://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
If you want help, then make it easy for someone to help you. Fix the code so that it is readable.
Explain what model you are fitting. If you are getting errors, that forces someone to guess what your real model is. You clearly have mistakes, but why force us to guess which mistakes you have made?
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!