How to combine specific columns from one array into another array
이전 댓글 표시
I have imported an excel spreadsheet as a string array and I need to pull out specific columns from this array that represent data obtained under certain conditions, to be used for further data processing
janimpedance is my 106x41 string array the relevant values are from rows 8 to 106. The first 7 rows contain charcters describing the conditions that were used in obtaining the data. I wanted to combine the values from every 6th column into a single array. I have been using newvariable=str2array((janimpedance(rowstart:rowstop,column)) to create the new variable and I was hoping to streamline the process so I don't have to manually enter the information for each variable.
Thanks
댓글 수: 5
James Tursa
2021년 2월 23일
Posting a small sample of data would help.
Brandon burns
2021년 2월 23일
편집: dpb
2021년 2월 23일
dpb
2021년 2월 23일
Better yet would be to attach the spreadsheet -- and read the numeric data as numeric instead of as string.
Looking at the results, it appears that
data=readtable('yourfile.ext','HeaderLines',6,'ReadVariableNames',0);
would work; resulting in a table with variable names Var1 thru Var5
Obviously the first variable is Frequency; I'm not sure how to interpret the Real/Imaginary components of the other four; you can set variable names as desired for convience with
data.Properties.VariableNames={'Frequency', 'ZImag', ...};
with a cell array of five names for the five columns.
Brandon burns
2021년 2월 24일
dpb
2021년 2월 24일
You can't have duplicated variable names, no, that would not lead to a way to unambiguously name a column by name.
Default names are Var1, Var2, ... VarN
If variables are related, here might be a place to use an array for the data instead and then refer to the desired column by indexing into the array.
Again, attaching a section of the actual file would help us help you...instead of guessing about stuff.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!