フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Dimension mismatch error while using FMINSEARCH

1 回表示 (過去 30 日間)
buxZED
buxZED 2011 年 3 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I keep getting this error message.
??? Subscripted assignment dimension mismatch.
Error in ==> fminsearch at 205
fv(:,1) = funfcn(x,varargin{:});
  1 件のコメント
Matt Tearle
Matt Tearle 2011 年 3 月 2 日
This contains even less information than the duplicate (2358), although the title is more descriptive. Any chance you can kill this one, and change the title of 2358? (Or kill 2358 and give more info here.) Otherwise we're going to end up with parallel discussions.

回答 (3 件)

Paulo Silva
Paulo Silva 2011 年 3 月 2 日
funfucn is returning more lines than you have in the variable fv
  1 件のコメント
buxZED
buxZED 2011 年 3 月 2 日
function J=P5Function(Sig)
global c2 z
J=0;
for k=1:201;
s1=c2*(k);
s2=exp(-z(k)^2/(2*(Sig)^2));
J=J+(s1-s2)^2;
end
above is a seperate M. file
below is what im trying to execute
tryed like 100 times, but cant find a errer
sig4=fminsearch('P5Function',1.5);% minimse the cost function using 'fminsearch' giving a predicted value for sigma4
c44=exp(-z.^2/(2*(sig4)^2));% Use global value for 'z' and predicted value for sigma4 to find a forth predicted value for average plume concentration ratio 'c'
e4=c2-c44;% calculate prediction error between global c2 (average plume concentration ratio) and the forth predicted plume concentration
pleese point me in the right derection

buxZED
buxZED 2011 年 3 月 2 日
any help?

Walter Roberson
Walter Roberson 2011 年 3 月 2 日
Answered in your duplicate question #2358
  2 件のコメント
buxZED
buxZED 2011 年 3 月 2 日
still gives the same error
?? Subscripted assignment dimension mismatch.
Error in ==> fminsearch at 205
fv(:,1) = funfcn(x,varargin{:});
Error in ==> Q5 at 99
sig4=fminsearch(@P5Function ,1.5);% minimse the cost function using
'fminsearch' giving a predicted value for sigma4
Walter Roberson
Walter Roberson 2011 年 3 月 2 日
At the beginning of your P5Function, put in
disp(size(Sig))
and at the end put in
disp(size(J))
fminsearch documents that the function needs to return a scalar output, but does not document what the array size passed in will be exactly. I believe that the array size passed in should be the same as the array size of the initial value, but it doesn't hurt to check experimentally.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by