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

조회 수: 13 (최근 30일)
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 CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by