What is wrong with this line of script?

1 回表示 (過去 30 日間)
Alice
Alice 2014 年 4 月 5 日
コメント済み: Alice 2014 年 4 月 5 日
I've written: [t,h] = ode45('cylinder_tank_drain', [0, 200], h0)
it keeps coming up with an error message what just says there is an error in this line. what is wrong? :(

採用された回答

Youssef  Khmou
Youssef Khmou 2014 年 4 月 5 日
Change r0 to :
r0=linspace(0.01,0.1,length(r));
  1 件のコメント
Alice
Alice 2014 年 4 月 5 日
Thanks :)

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

その他の回答 (3 件)

Walter Roberson
Walter Roberson 2014 年 4 月 5 日
There is no obvious error in that line. Perhaps there is an error in the previous line that is affecting it. Please post more of your script.
Also, I suggest converting to function handle form:
[t, h] = ode45(@cylinder_tank_drain, [0, 200], h0);

Youssef  Khmou
Youssef Khmou 2014 年 4 月 5 日
The problem resides in the function "cylinder_tank_drain", if it is possible you post the function to study its input and outputs.

Alice
Alice 2014 年 4 月 5 日
編集済み: Walter Roberson 2014 年 4 月 5 日
function [ dhdt ] = cylinder_tank_drain( t, h)
%draining of a uniform cross sectional area tank (cylinder)
r = [1:0.5:6];
A = pi.*r.^2;
r0 = [0.01:0.01:0.1];
a0 = pi.*r0.^2;
g = 9.8;
dhdt = (-a0.*sqrt(2*g.*h))./A;
  2 件のコメント
Walter Roberson
Walter Roberson 2014 年 4 月 5 日
Your "r" is length 11. Your "r0" is length 10. You are trying to combine two vectors of different lengths.
Alice
Alice 2014 年 4 月 5 日
Thanks!!

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

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by