how to copy values from one table to other table

6 ビュー (過去 30 日間)
Shambhavi Adhikari
Shambhavi Adhikari 2019 年 4 月 10 日
コメント済み: madhan ravi 2019 年 4 月 10 日
Hi,
I have a table with a columns of say 10 values from 1 to 10 and I have an array of 5 values with values as 2, 4, 6, 7,8. How do i create a new column in the table which will copy the data from the array match with the table values and fill Nan on those values which are not same?
Like this
New_row
Nan
2
Nan
4
Nan
6
7
8
Nan
Nan

回答 (3 件)

madhan ravi
madhan ravi 2019 年 4 月 10 日
編集済み: madhan ravi 2019 年 4 月 10 日
T1=table((1:10).');
T2=table([2, 4, 6, 7, 8].');
outerjoin(T1,T2)
  1 件のコメント
Shambhavi Adhikari
Shambhavi Adhikari 2019 年 4 月 10 日
If both of them are tables? How to do it?

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


Shambhavi Adhikari
Shambhavi Adhikari 2019 年 4 月 10 日
I ran into this error
Error using tabular/outerjoin (line 148)
Cannot find a common table variable to use as a key variable.
Error in new_code (line 12)
T=outerjoin(T,T2);
  1 件のコメント
madhan ravi
madhan ravi 2019 年 4 月 10 日
編集済み: madhan ravi 2019 年 4 月 10 日
You have problems with copying the code correctly. Go back, copy my answer and paste it in the command window.

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


Shambhavi Adhikari
Shambhavi Adhikari 2019 年 4 月 10 日
Now this error
Error using tabular/outerjoin (line 148)
Left and right key variables 'Var1' and 'Var1' do not have the same number of columns.
Error in new_code (line 13)
T=outerjoin(T,T2);
  2 件のコメント
Shambhavi Adhikari
Shambhavi Adhikari 2019 年 4 月 10 日
I did copy it in command window.. Same error..
Error using tabular/outerjoin (line 148)
Left and right key variables 'Var1' and 'Var1' do not have the same number of columns.
madhan ravi
madhan ravi 2019 年 4 月 10 日
Upload the code your trying.

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by