How to convert the present data into another format?

조회 수: 1 (최근 30일)
Bhavnish
Bhavnish 2014년 9월 24일
댓글: Bhavnish 2014년 9월 26일
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일
temp = [a; b; c; d; e; f]';
  댓글 수: 6
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일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by