フィルターのクリア

Subscripted assignment dimension mismatch in for loop

1 回表示 (過去 30 日間)
Arbol
Arbol 2017 年 6 月 11 日
コメント済み: Star Strider 2017 年 6 月 11 日
Does anyone know what's wrong with this? I have tdatas and tissdatas with size (225x4). Every time I run this, I get the following error: Subscripted assignment dimension mismatch. Where am I wrong in this code? I just don't understand it or find it.
for i=1:length(tdatas(1,:))
fun = @(p,tdatas) objfunction(p,tdatas,tu);
z(i)=lsqcurvefit(fun,param0,tdatas(:,i),...
tissdatas(:,i),[0 0 0 0],[1 1 1 1],options);
end
  1 件のコメント
Arbol
Arbol 2017 年 6 月 11 日
Or the following: In an assignment A(:) = B, the number of elements in A and B must be the same.

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2017 年 6 月 11 日
You are estimating and returning 4 parameters, and assigning them to a 1 dimensional scalar. I do not know whether you are returning row or column vectors, so the easiest way is to use ‘z’ as a cell array:
z{i} = lsqcurvefit(fun,param0,tdatas(:,i),...
tissdatas(:,i),[0 0 0 0],[1 1 1 1],options);
Note the curly brackets ‘{}’ denoting cell array indexing.
  4 件のコメント
Arbol
Arbol 2017 年 6 月 11 日
編集済み: Arbol 2017 年 6 月 11 日
Oh sorry, yes, you are right! It will return 4 parameters. You are the best man! haha
Star Strider
Star Strider 2017 年 6 月 11 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by