Storing the strings of a table data while using a loop?

4 visualizaciones (últimos 30 días)
Surjeet Sarangi
Surjeet Sarangi el 12 de Sept. de 2022
Comentada: Surjeet Sarangi el 16 de Sept. de 2022
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 comentario
dpb
dpb el 12 de Sept. de 2022
Editada: dpb el 12 de Sept. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 12 de Sept. de 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.
  1 comentario
Surjeet Sarangi
Surjeet Sarangi el 16 de Sept. de 2022
Thanks, but i got the issue resolved by converting table to structure, then performing required operations

Iniciar sesión para comentar.

Categorías

Más información sobre Tables en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by