Error: Function value and YDATA sizes are not equal
8 ビュー (過去 30 日間)
古いコメントを表示
I have a fitting code with lsqcurvefit function. I am having this error "Function value and YDATA sizes are not equal"(line 251). Please give your suggestion to solve it.
clear all, close all, clc
EQE = xlsread('EQERollOff','Sheet1','A30:B55');% loading raw data from excel file
x = EQE(:,1);% Current
y = EQE(:,2);% EQE
%parameter estimation
J0 = [6];
options = optimset('Algorithm', 'trust-region-reflective');
[J,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@EQEFit,J0,x,y)
function s = EQEFit(J,x)% function for fitting
s = J(1)/(4*x)*(sqrt(1+8*(x/J(1)))-1)*5
end
Size of x = 26 1, Size of y = 26 1
0 件のコメント
採用された回答
Rik
2019 年 1 月 22 日
As a bold guess I'm going to assume you meant this:
function s = EQEFit(J,x)% function for fitting
s = J(1)./(4*x).*(sqrt(1+8*(x/J(1)))-1)*5;
end
(I don't have the Optimization Toolbox, so I can't test the code)
3 件のコメント
Rik
2019 年 1 月 29 日
There are two operations here that are potentially matrix operations: the division and multiplication. Since the multiplication returns a vector, this would be equivalent to finding an inverse for that vector and then multiplying that with J(1).
so this:
J(1)/(4*x)
is parsed like this:
J(1) * 1/(4*x)
The most important thing is to be aware that these operators have two imputs: the prior term and the second term.
The more practical thing is to watch out with these, and adding a dot when in doubt:
*/^'
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!