How to create many variables from a dataset?

조회 수: 1 (최근 30일)
Md. Golam Mostafa
Md. Golam Mostafa 2015년 9월 24일
편집: Stephen23 2019년 6월 19일
I have a dataset having 369148 rows organised in two columns. Every 26 rows of the first column contains a specified scale and the next 26 rows a different scale and so on. Second column contains measurement values at every specified scale. Therefore, total 14198 scales each having 26 measurement values making a grand total of measurement values in the second column is 369148. I want to create 14198 variables for every specified scales each having 26 measurement values. Can someone help me out.

답변 (3개)

Steven Lord
Steven Lord 2015년 9월 24일
DON'T DO THIS. See question 1 in the Programming section of the FAQ for an explanation.
Reshape the original data set so that each of your "variables" is stored as a column of the data.
  댓글 수: 1
Md. Golam Mostafa
Md. Golam Mostafa 2015년 9월 24일
Sorry, I am a novice in using MATLAB. Can you explain me further?

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


Stephen23
Stephen23 2015년 9월 25일
편집: Stephen23 2019년 6월 19일
  댓글 수: 2
Md. Golam Mostafa
Md. Golam Mostafa 2015년 9월 25일
Thank you very much for your enlightening comment! I shall read all these stuffs and follow best practices.
Stephen23
Stephen23 2015년 9월 25일
편집: Stephen23 2015년 9월 25일
Enjoy reading! Basically you should keep your data together as much as possible, because this makes MATLAB fast, and is neater to code. Learn to use the dimensions of numeric arrays rather than splitting up your data:

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


Thorsten
Thorsten 2015년 9월 25일
You can reshape your data
data = reshape(data, 26, 14198, 2);
You can even let Matlab figure out the elements along the 2nd dimension
data = reshape(data, 26, [], 2);

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by