Trying to find row numbers from array inside cell array entry

I'm trying to access data in a matrix inside of a cell array to reference it later. The data won't convert into a matrix using cell2mat because all the variables inside are numbers that extract as character vectors. Using str2num on the data doesnt work either. How can I get the matrix out of the cell array so I can access and reference it? I've been using the following extraction command:
Extraction code:
[data, delimiterOut, headerlinesOut]=importdata(filename);
The file I'm extracting from is a tab-delimited text file.

4 Kommentare

Have to see the file to be able to tell anything for sure
here is a sample of the data file that it should come out to after cleaning up the headings and side notes
@Cameron LaCourse: please upload the input data file. So far we have nothing to work with.
Understood. Here is the input data file. My apologies, I wasn't sure if I was allowed to share it at first. I also use this line to name the filename variable, if this helps.
filename = sprintf('Text%d 1-10.txt',txtnum);
Where txtnum is input and error-checked as a whole positive number.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Stephen23
Stephen23 am 23 Mai 2021
Bearbeitet: Stephen23 am 23 Mai 2021
T = readtable('Text1 1-10.txt', 'Delimiter','\t')
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
T = 17928×20 table
ParticNumber ElapsedTime_s_ LongAcceleration_feet_second_2_ LatAcceleration_feet_second_2_ LongVelocity_feet_second_ LVMPH LatVelocity_feet_second_ TotalLongDistance_f_ LateralLanePos_feetFromCenterLine_ SteeringWheelAngleInput_degrees_ x_OfCrashes SteeringInputCounts GasPedalInputs CurrentSpeedLimit_f_s_ UpperAccControl LowerAccControl UpperLanePosCont LowerLanePosControl Var19 Var20 ____________ ______________ _______________________________ ______________________________ _________________________ ______ ________________________ ____________________ __________________________________ ________________________________ ___________ ___________________ ______________ ______________________ _______________ _______________ ________________ ___________________ ______________ ________ 1 105.19 -0.28 0 65.56 44.699 0 6002.2 18.53 0 0 32767 45485 66 47.04 42.96 18.864 17.136 {'P1' } NaN 1 105.22 -0.28 0 65.55 44.692 0 6004.4 18.53 0 0 32767 45485 66 47.04 42.96 18.864 17.136 {'Acc Mean' } -0.16023 1 105.25 -0.33 0 65.54 44.685 0 6006.6 18.53 0 0 32767 45745 66 47.04 42.96 18.864 17.136 {'Veloc Mean'} 40.333 1 105.29 -0.33 0 65.53 44.678 0 6008.8 18.53 0 0 32767 45745 66 47.04 42.96 18.864 17.136 {'StDev' } 0.4519 1 105.32 -0.32 0 65.52 44.672 0 6010.9 18.53 0 0 32767 45745 66 47.04 42.96 18.864 17.136 {0×0 char } -0.4519 1 105.35 -0.32 0 65.51 44.665 0 6013.1 18.53 0 0 32767 45745 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.39 -0.32 0 65.5 44.658 0 6015.3 18.53 0 0 32767 45745 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.42 -0.31 0 65.49 44.651 0 6017.5 18.53 0 0 32767 45745 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.45 -0.31 0 65.48 44.644 0 6019.7 18.53 0 0 32767 45745 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.49 -0.31 0 65.47 44.637 0 6021.9 18.53 0 0 32767 45745 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.52 -0.41 0 65.45 44.624 0 6024 18.53 0 0 32767 46265 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.55 -0.41 0 65.44 44.617 0 6026.2 18.53 0 0 32767 46265 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.59 -0.4 0 65.42 44.603 0 6028.4 18.53 0 0 32767 46265 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.62 -0.4 0 65.41 44.597 0 6030.6 18.53 0 0 32767 46265 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.65 -0.4 0 65.4 44.59 0 6032.8 18.53 0 0 32767 46265 66 47.04 42.96 18.864 17.136 {0×0 char } NaN 1 105.69 -0.39 0 65.38 44.576 0 6034.9 18.53 0 0 32767 46265 66 47.04 42.96 18.864 17.136 {0×0 char } NaN

3 Kommentare

Am I able to edit/reference a table as I would an array?
The link Stephen gave above shows all the ways (a veritable cornucopia) to address table variables. The table itself is a container class, though, not a variable in quite the same sense as the single array variable. But, tablename.variablename returns an array that you can index like any other.
Again, read the doc/look at the examples...
Thank you very much! This should help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by