Undefined function 'times' for input arguments of type 'struct'.

13 ビュー (過去 30 日間)
Antonio José Jiménez
Antonio José Jiménez 2016 年 2 月 19 日
Good afternoon!
I´m solving a ODE45 (RK.m) and I want to introduce in the function "maqi.m" an inlet variable called "SOC_1" because its necessary to solve the code. If I do it, Matlab returns me "Undefined function 'times' for input arguments of type 'struct' "
Where is the wrong?
Next attached the files.
Thank you so much.
  1 件のコメント
Stephen23
Stephen23 2016 年 2 月 19 日
編集済み: Stephen23 2016 年 2 月 19 日
Please show make a comment and show us the complete error message. This means all of the red text.
You also need to show us how you are calling your functions, because we cannot read your mind.

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

採用された回答

Stephen23
Stephen23 2016 年 2 月 19 日
編集済み: Stephen23 2016 年 2 月 19 日
There is nothing wrong with the variable SOC_1 inside maqi.m: every instance performs some numeric operation. The problem is that you are calling maqi with a structure for that input variable, whereas it should be numeric.
But because none of your supplied files actually call maqi, it is difficult to give much more advice than this. You need to show us exactly how you are calling maqi, and also provide us with the complete error message.
It is also quite possible that you are using the incorrect outputs from your Parametros function: it returns almost fifty individual output arguments! OUCH! This is an extremely buggy way to write code, because it is quite likely that one (accidentally) missing output argument means the other variables are allocated to different variable names than you think they have been. The simplest solution is to avoid using lots of output arguments and put all of those arguments into one simple structure:
function params = Parametros()
params.D = 1;
params.S = 2;
params.rc = [4,5m6];
end
then you only need to call Parametros like this:
S = Parametros();
and use them like this:
S.rc
S.D
then all of your parameters are passed easily without putting fifity individual arguments. Buggy programs come by design, and it is your job as the designer to make them less buggy by using good design!
  1 件のコメント
Antonio José Jiménez
Antonio José Jiménez 2016 年 2 月 22 日
The file "RK.m" call to maqi.m. When I run it, the wrong appear in the workspace. They are the only files I have.
Thank you for your advice.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by