Error using table (line 253) All variables must have the same number of rows.

114 ビュー (過去 30 日間)
Ali Mulhi
Ali Mulhi 2019 年 3 月 15 日
コメント済み: Peter Perkins 2019 年 3 月 18 日
i don't know why there's an error with my table. all varibales have 25 values.
here's my code
step= (0.0:0.2:5)';
Psi0= psiO(:,1)';
Psi1= psiO(:,6)';
Psi2= psiO(:,11)';
Psi3= psiO(:,16)';
Psi4= psiO(:,21)';
Psi5= psiO(:,26)';
table(step,Psi0,Psi1,Psi2,Psi3,Psi4,Psi5)
  3 件のコメント
Ali Mulhi
Ali Mulhi 2019 年 3 月 15 日
i examined all my values in the table. They all have 25 values. i don't know what's wrong?!
per isakson
per isakson 2019 年 3 月 17 日
編集済み: per isakson 2019 年 3 月 17 日
step= (0.0:0.2:5)';
>> length( step )
ans =
26

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

採用された回答

KSSV
KSSV 2019 年 3 月 15 日
編集済み: KSSV 2019 年 3 月 15 日
The first input is a column and rest are rows..so the error. Try:
table(step,Psi0',Psi1',Psi2',Psi3',Psi4',Psi5')
You need to rethink on your code. The initilaization and calling th eindices is not good.
  3 件のコメント
KSSV
KSSV 2019 年 3 月 15 日
It is not strange.......either you should input all rows or columns.....in my case I used all columns.
YOu have transposed the first input to a row from columna nd rest all are rows....
Ali Mulhi
Ali Mulhi 2019 年 3 月 15 日
I got it. Thanks Sir!

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

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2019 年 3 月 15 日
Psi0 = array2table(psi0(:,[1 6 11 16 21 16])
would have been helpful for this. And then addvars to add step at the beginning.
  2 件のコメント
Guillaume
Guillaume 2019 年 3 月 15 日
編集済み: Guillaume 2019 年 3 月 15 日
or
[table(step), array2table(psi0(:,[1 6 11 16 21 16]))]
Either of these is a lot simpler than temporary numbered (!) variables.
Is there any difference between addvars and table concatenation?
Peter Perkins
Peter Perkins 2019 年 3 月 18 日
addvars lets you add new variables in the middle. It's really the only reason why it even exists.

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

カテゴリ

Help Center および File ExchangeSignal Generation and Preprocessing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by