フィルターのクリア

"error using vercat"?

4 ビュー (過去 30 日間)
Susan Santiago
Susan Santiago 2018 年 5 月 10 日
回答済み: KSSV 2018 年 5 月 10 日
I'm getting this error "Error using vertcat The following error occurred converting from double to function_handle: Too many output arguments"
here's my code
m1=55;
m2=400;
m3=100;
k1=230000;
k2=30000;
k3=50000;
k4=3000;
n2=1500;
n3=4000;
n4=700;
ti=0;
tf=20;
tm=(ti+tf)/2;
t1=tf/4;
L0=5;
v=15;
A=0.03;
M=[0 1 0 0 0 0;
-(k1+k2)/m1 -(n2+n4)/m1 k2/m1 n4/m1 0 n4/m1;
0 0 0 1 0 0;
k2/m2 n2/m2 -(k3+k2)/m2 -(n3+n2)/m2 k3/m2 n3/m2;
0 0 0 0 0 1;
k4/m3 n4/m3 k3/m3 n3/m3 -(k3+k4)/m3 -(n3+n4)/m3];
fM= @(t,y) M*y+vect;
%Scenario 1
u1 = @(t) (A/2)*[1-cos(2*pi*v*t/L0)]
vect=[0;u1;0;0;0;0];
[T, Y1] = ode45(fM,[ti,tf],vect)
I'm going to say upfront that I'm not totally sure if this code even makes sense so any help would be appreciated
  1 件のコメント
Greg
Greg 2018 年 5 月 10 日
編集済み: Greg 2018 年 5 月 10 日
As the second error states, it can't convert a double to a function handle:
u1 = @(t) (A/2)*[1-cos(2*pi*v*t/L0)]
vect=[0;u1;0;0;0;0];
u1 is a function handle, and you're trying to merge it with a matrix of zeros (class double). What are you hoping vect will be?

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

採用された回答

KSSV
KSSV 2018 年 5 月 10 日
As u1 is a function handle it needs t as input...you input t into it and then call the line you wanted.
t = 0:0.001:1 ;
vect=[0;u1(t)';0;0;0;0];

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by