fitting a certain function up to a certain x-value

조회 수: 3 (최근 30일)
Ahmed Elsherif
Ahmed Elsherif 2020년 2월 26일
댓글: Ahmed Elsherif 2020년 2월 26일
Hello,
I have data in a two coulmns-excel file and I load them then I perform a fitting using a defined equation. I need to perform the fitting until a user defined value of x-axis. To have an equal length of x and y, I tried to look for the y value corresponding to the given x value. The code is:
dataset = xlsread('input.xlsx');
E=dataset(:,1);
F3g=dataset(:,2);
%Equation
f = @(x,Edata)(x(1)+(x(2)-x(1))*exp(-0.5*(Edata/x(3)).^x(4)))./(1+(Edata/x(5)).^1.6)+x(6)*((x(7)-x(8))./(Edata/x(9))+x(8));
x0 = [0 0 0 1 1 1 0 1 0];
Ev=getappdata(0,'edit3'); % this is an editable value by user
Z=F3g(E==Ev); % I try to get the value of F3g corresponding to Ev to have equal lengths
options = optimoptions('lsqnonlin','Display','iter');
[x,resnorm,~,exitflag,output] = lsqcurvefit(f,x0,E(1:Ev),F3g(1:Z),[],[], options) % fitting
1-It does not work and it shows the error;
Error using ==
Matrix dimensions must agree.
2-Also, If I set manually the number of column of F3g corresponding to the given value of Ev, e.g.,
[x,resnorm,~,exitflag,output] = lsqcurvefit(f,x0,E(1:Ev),F3g(1:19),[],[], options) % fitting
it shows the following error!
Error using :
For colon operator with char operands, first and last operands must be char.
it works only with
[x,resnorm,~,exitflag,output] = lsqcurvefit(f,x0,E(1:19),F3g(1:19),[],[], options) % fitting
But without using Ev while I need to use it. Any help or hints?
Thanks in advance
  댓글 수: 2
Alex Sha
Alex Sha 2020년 2월 26일
Hi, upload your data file please.
Ahmed Elsherif
Ahmed Elsherif 2020년 2월 26일
here you are

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by