How to solve this issue?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
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 件のコメント
Ali Najem
2020 年 3 月 21 日
thank you so much for reply
you mean in symbolic file i have to use double function ?
Star Strider
2020 年 3 月 21 日
As always, my pleasure!
Keep the values symbolic in the symbolic part of your code. In the numeric part (the ode15s call) they must not be symbolic, so use the double function to convert them from symbolic to double.
Steven Lord
2020 年 3 月 21 日
You can use symbolic variables and functions inside your ODE function. The ODE solver doesn't really care what your ODE function does internally (within reason. If you have your ODE function just generate random data, it's going to generate a random solution for example.)
But what your ODE function returns to the ODE solver ode15s must be a single or double array. So just before the end of your ODE function, if the values it would return aren't single or double, use single or double to convert them to the appropriate type.
Ali Najem
2020 年 3 月 22 日
ohh understood thank you for your answering sir
Ali Najem
2020 年 3 月 23 日
can you tell me how to conver to double function i tried many times but i didn't get results
when i run symbolic file i got some parameters how to convert it to double befor go to another file
please i hope to assit me
thanks advance.
Star Strider
2020 年 3 月 23 日
I do not understand what you are asking.
The double function will work if you have purely numeric symbolic values. If you have symbolic variables as well, double will not work. All the symbolic variables must have values (so the expression becomes purely numeric) in order to use the double function.
Ali Najem
2020 年 3 月 23 日
sorry to disturb you sir but all my symbolic are variables when i run symbolic file i want to use these results in symbolic to another file if i make it copy and paste it's works but i need way to passed it without copy and paste due to the equations are so long
thnk you so much indeed
Star Strider
2020 年 3 月 23 日
I do not understand.
Consider using the save funciton to save them to a .mat file, then load that .mat file in the code you want to use them in.
Ali Najem
2020 年 3 月 23 日
i used already but when i load it for examble: load a. mat aw1 a2w1 a3w1 a4w1 a5w1 a6w1 a7w1
and i want to use thsese variables in b.file for examble i got this error (Inputs must be floats, namely single or double).
Ali Najem
2020 年 3 月 23 日
thank you sir for giving your time to try solve my problem i hope you found my issue. Is there any way to run a.m file and get the results from a.m and use it in b.m file ?
note: a.m file is like this :
syms w1
n=x1*w1
aa=diff(n,w1)
i need to use aa in b.m file
am so grateful to you sir..
Star Strider
2020 年 3 月 23 日
i do not understand the problem you are experiencing. If you want to use them as symbolic, the .mat file approach should work. If you want to use them as numeric, they need to be double values. I cannot add anything more than I already have discused. I do not have enough information.
Ali Najem
2020 年 3 月 23 日
Alright, sir i appreciate that
maybe the problem in call file it should be numeric though, i cannot how to convert to double values.
thank you so much..
Star Strider
2020 年 3 月 23 日
As always, my pleasure.
I cannot comment because I do not have your code.
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 件)
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
