How to convert the present data into another format?

I have data in the following format. temp = a: [1x315 double] b: [1x315 double] c: [1x315 double] d: [1x315 double] e: [1x315 double] f: [1x315 double]
I need to convert this data into following format: temp = data: [315x6 double] var: {'a' 'b' 'c' 'd' 'e' 'f'} Please suggest how should I do this conversion.

 採用された回答

Roger Wohlwend
Roger Wohlwend 2014 年 9 月 25 日

0 投票

temp = [a; b; c; d; e; f]';

6 件のコメント

Bhavnish
Bhavnish 2014 年 9 月 25 日
Hi Roger, Thanks for providing an answer. temp = [a; b; c; d; e; f]'; will do the transpose of data and store the data in variable 'temp'.
But I am in need to make temp = data: [315x6 double] var: {'a' 'b' 'c' 'd' 'e' 'f'}. So that I can type 'temp.data' & 'temp.var' to get the reqd values.
Stephen23
Stephen23 2014 年 9 月 25 日
This is not clear: you accepted the answer, but state you need a different output... Is the problem resolved?
Joseph Cheng
Joseph Cheng 2014 年 9 月 25 日
Just another case of accepting the wrong answer. Happens all the time. Glad i'm not here for the points. (well at least for now. There is a huge gap until the next Reputation Privilege)
Stephen23
Stephen23 2014 年 9 月 25 日
True, points are one thing... but if they really want help, marking the problem as being resolved makes any browsing user think that the asker doesn't need any more help... which contradicts their statements.
Joseph Cheng
Joseph Cheng 2014 年 9 月 25 日
which in this case would be fine. I usually read all entries to an accepted question as sometimes people comeback with different methodologies. But yes in general somehow people are confused with posting here. (the {}code button is a prime example)
Bhavnish
Bhavnish 2014 年 9 月 26 日
Roger, Joseph, if we combine the answer from both of you, then data conversion that I was looking for happens succesfully.
However, mathworks doesn't allow me to combine and accept the answer. Once, I clicked on the Accepted answer of Roger, it didn't aloow me to do anything else. I am sorry to create the confusion here.

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

その他の回答 (1 件)

Joseph Cheng
Joseph Cheng 2014 年 9 月 25 日

2 投票

to expand on Roger's answer you you can build the structure like this
a = randi(10,1,351);
b = randi(10,1,351);
c = randi(10,1,351);
d = randi(10,1,351);
e = randi(10,1,351);
f = randi(10,1,351);
temp.data = [a; b;c;d;e;f]';
temp.var = {'a' 'b' 'c' 'd' 'e' 'f'};

1 件のコメント

Bhavnish
Bhavnish 2014 年 9 月 25 日
Hey Joseph, This works well.
Thanks a lot Joseph and Roger.

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

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

製品

質問済み:

2014 年 9 月 24 日

コメント済み:

2014 年 9 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by