Variable for table are in one row and not one column. How do I turn it or save a variable in one column?

25 ビュー (過去 30 日間)
Very Basic but i just cant find the answer to my problem. Looking for 2 Solutions.
  1. How do I safe data in one column and not one row?
  2. How can I change the orientation in the table even if my varibales are in one row?
data = [1:number]
t = table(data,'VariableNames',{'Set number'})
Results:
Set Number
1 2 3
What I am looking for:
Setnumber
1
2
3

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 29 日
編集済み: Ameer Hamza 2020 年 11 月 29 日
You can use the transpose operator
data = (1:number).';
or indexing
data = 1:number;
data = data(:)
or reshape()
data = reshape(1:number, [], 1)
To only change the orientation in the table
data = 1:number
t = table(data.','VariableNames',{'Set number'})
or any of the above mentioned options.

その他の回答 (1 件)

KSSV
KSSV 2020 年 11 月 29 日
number = 3 ;
data = [1:number]'
data = 3×1
1 2 3
t = table(data,'VariableNames',{'Set number'})
t = 3x1 table
Set number __________ 1 2 3

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by