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

Posting a small sample of data would help.
"% Module: Sweep, ID: c0p1t9p1cfm0" "" "" "" ""
"% Devices: DEV4351" "" "" "" ""
"% Time: 2021/01/11 17:44:51" "" "" "" ""
"% Impedance 1 Sample Imag(Z), /dev4351/imps/0/sample.ImagZ" "" "" "" ""
"% Impedance 1 Sample Real(Z), /dev4351/imps/0/sample.RealZ" "" "" "" ""
"% Frequency (Hz)" " Impedance 1 Sample Imag(Z) Impedance (Ohm)" " Impedance 1 Sample Real(Z) Impedance (Ohm)" "" ""
"1" "21.44048776" "4573.587521" "-21.44048776" "-163.2117738"
"1.141963503" "-21.04963158" "4612.747323" "21.04963158" "137.9444578"
"1.304080641" "-24.82972845" "4636.269237" "24.82972845" "141.0451397"
"1.489212497" "25.28507847" "4623.18278" "-25.28507847" "-126.4890328"
"1.700626319" "13.23952088" "4645.459287" "-13.23952088" "-57.44376346"
"1.942053188" "-2.400680934" "4622.61499" "2.400680934" "9.211664584"
"2.217753861" "8.295295304" "4629.761629" "-8.295295304" "-27.78690695"
"2.532593967" "-17.98209042" "4622.546068" "17.98209042" "52.91099117"
"2.892129877" "12.89723478" "4615.162084" "-12.89723478" "-33.33817811"
"3.302706765" "7.474625656" "4561.41374" "-7.474625656" "-17.32047063"
This is just a small section of the data that makes up the string array. I need to combined the columns of the impedance measurements into unique arrays to make it easier to process the data later on.
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.
Is it possible to repeat the VariableNames. As the table I'm looking at have 40 to 50 variables. I would rather not have to name them all I was hoping to name the first 6 variables and have it repeat over the remaining columns.
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에 대해 자세히 알아보기

태그

질문:

2021년 2월 23일

댓글:

dpb
2021년 2월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by