Assignment has more non-singleton rhs dimensions than non-singleton subscripts
이전 댓글 표시
clc
clear
%Experimental data
xdata=[30 30 30 ;...
60 60 60 ;...
90 90 90 ;...
120 120 120;...
150 150 150;...
180 180 180];
ydata=[0.031 0.033 0.029;...
0.053 0.053 0.052;...
0.066 0.071 0.065;...
0.078 0.077 0.077;...
0.085 0.083 0.087;...
0.089 0.091 0.088];
k=0.01;
%The empty vector [] is a signal to Matlab to use the default options
options=[];
K=fminsearch(@SumErrorSquared, k, options, xdata, ydata);
%plot the results
clf
plot(xdata,ydata, '.r')
hold on
plot(xdata, (0.2/2)*(1-exp(-2*K*50*xdata/200)))
my function file
function r2 = SumErrorSquared(k,xdata,ydata)
k=k(1);
yfit =(0.2/2)*(1-exp(-2*k*50*xdata/200));
r = yfit - ydata; %residuals
%pause MATLAB for 0.1 seconds to give time to display plot
clf
plot(xdata,ydata, '.r')
hold on
plot(xdata, yfit)
pause(0.1)
r2 = sum(r.^2);
and I get this
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in fminsearch (line 200)
fv(:,1) = funfcn(x,varargin{:});
Error in bestfitline (line 11)
K=fminsearch(@SumErrorSquared, k, options, xdata, ydata);
can you help me please
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!