How to solve this issue?

조회 수: 1 (최근 30일)
Ali Najem
Ali Najem 2020년 3월 21일
댓글: Steven Lord 2020년 3월 23일
Hello there,
I got this error when i use ODE15s solver :
Error using odearguments (line 113)
Inputs must be floats, namely single or double.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in simple (line 44)
[T1,cox]=ode15s(@(t,y1) Costatesimple(t,y1,u,x1,x2,yd,x1t,e1,w1,w2,w3,w4,v1,v2),tspan2,[0 0 0 0 0 0 0],options);
any help please?
Note: i used syms in diffrent file to get some parameters and save it as a datafile then load it in Costatesimple file...
thank you so much indeed

채택된 답변

Star Strider
Star Strider 2020년 3월 21일
If the extra parameters (or any other values) you are passing to ‘Costatesimple’ are symbolic, (and do not contain any symbolic variables), it will be necessary to use the double function to convert them to double-precision values that ode15s can use.
  댓글 수: 14
Star Strider
Star Strider 2020년 3월 23일
As always, my pleasure.
I cannot comment because I do not have your code.
Steven Lord
Steven Lord 2020년 3월 23일
Save the following code as example512084.m and try running it. The first ode45 call uses a function (thisWillNotWork) that returns a sym value to ode45 and so that won't work. If you comment out that call and uncomment the second ode45 call, it will work because while thisWillWork uses symbolic calculations internally what it returns to ode45 is a double array.
function sol = example512084
sol = ode45(@thisWillNotWork, [0 5], 1);
% sol = ode45(@thisWillWork, [0 5], 1);
function dydt = thisWillNotWork(~, y)
two = sym(2);
dydt = two*y; % dydt is symbolic
function dydt = thisWillWork(~, y)
two = sym(2);
dydt = two*y; % dydt is symbolic
dydt = double(dydt); % dydt is now double

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by