What is generating "Subscript indices must either be real positive integers or logicals" in my code?

6 ビュー (過去 30 日間)
I have attached my code. I know the error happens in my mathematical expression, I just don't understand exactly what the error is telling me. Lines 14-20 show a mathematical function I created to fit my data and that I want to use in a non-linear squares fit to optimize two parameters: p1 and p2. Please help me figure out what this error is saying in my situation. Thanks!

採用された回答

Jan
Jan 2017 年 4 月 4 日
編集済み: Jan 2017 年 4 月 4 日
Please do not code as screenshot, but as text. Then the readers can use it by copy&paste.
matlabFunction is a 79282x1 vector. In you code you try to evaluate it as a function with non-integer indices. This cannot work. Simplified:
x = 1:3
x(2.7) % ERROR!
  2 件のコメント
Kelly McGuire
Kelly McGuire 2017 年 4 月 4 日
編集済み: Kelly McGuire 2017 年 4 月 4 日
Sorry about that. So, I shouldn't use matlabFunction? I tried, now, doing modelFun = @(p,VarName1) before the function, and it isn't a 79282x1 vector anymore, but now it's saying not enough input arguments.
Jan
Jan 2017 年 4 月 5 日
Please post the code and the complete error message.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2017 年 4 月 5 日
We see this several times a day or week. So, since it's a VERY Frequently Asked Question, I just refer you to the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by