How to solve this issue?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Najem
am 21 Mär. 2020
Kommentiert: Steven Lord
am 23 Mär. 2020
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
0 Kommentare
Akzeptierte Antwort
Star Strider
am 21 Mär. 2020
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 Kommentare
Star Strider
am 23 Mär. 2020
As always, my pleasure.
I cannot comment because I do not have your code.
Steven Lord
am 23 Mär. 2020
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
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!