Storing the strings of a table data while using a loop?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am processing a table data, in which I have some columns which contain strings and some columns which contain numeric values. In order to use the numeric values of the table I used "readmatrix(data)". In this process all the string values are stored as "NaN". Now when i try to use "readtable(data)", I can't the use the numeric values in my script. The data I am using in given for an example as below:

Somewhere in the process I need to store the strings multiple times in a loop. How to do that?
1 Kommentar
dpb
am 12 Sep. 2022
Bearbeitet: dpb
am 12 Sep. 2022
Appears you're heading down the wrong direction here...with disparate data types, use readtable instead and then refer to the data fields by variable name -- you'll get the type of the data already in hand.
It appears from the screen shot at least some of your variables consist of multiple pieces of data that should be separate variables instead -- particularly the columns 3-5 should be parsed to provide the current for Tc and then the R values and conditions of measurement as separate variables Rds,Cds,Vds, say.
Then, when you have the table, groupsummary and friends will let you process the data in whatever manner you wish with grouping variables to categorize by whatever choice of parameters is desired. You do NOT need to and SHOULD NOT split out the data from the table into a bunch of separate variables once the table is constructed.
Antworten (1)
Walter Roberson
am 12 Sep. 2022
Use detectImportOptions() for the file, and use setvartype() 'string' for the columns containing mixed data.
Afterwards you will need to extract the relevant numeric values from the entries stored.
In the particular case of DrainToSourceVoltage_V (whatever the name is), there is another possibility: you could set the variable type to double, but also set the 'Suffix' option to ' V' to cause the ' V' to be stripped before attempting to convert to numeric.
You might not be able to do the same thing for Current_ContinuousDrain as some of the entries do not have the ' (Tc)' suffix... I do not recall at the moment whether you can configure multiple suffixes.
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!