Converting string to number

Hello All,
I need to convert a hug string data to numbers. The data is save in a variable based on the following command such that each row can lead to another huge matrix of data. So how can I convert this to numbers of class double?
for i = 1:1000
PowersScenario1(i+j1,:)={num2str(i) [csvread('ieee123_EXP_POWERS.CSV',1,1)]};
end
Thanks in advance.
Yara Hassan

6 comentarios

DGM
DGM el 16 de Jun. de 2022
It's not clear what's actually in the output array. It's a cell array, where the first column contains char vectors converted from scalar integers. The second column contains a thousand copies of the same array of unknown size. I assume the array is ostensibly numeric.
If those array copies are already numeric, then the only non-numeric content in the cell array is in column 1, which was intentionally converted from numeric. The solution would be to simply not create the problem in the first place.
Since it's unclear what the geometry of the array copies in column 2 are (or expected to be), it's not really clear whether it's expected that the cell array can be converted into a numeric array. It's also not clear why you'd need a thousand copies of the same array. If this is just prototype code and those offsets change in the loop, then it's not even clear that the resultant arrays would have the same size.
Image Analyst
Image Analyst el 16 de Jun. de 2022
Where is the hug string? i is a small number, and csvread returns an array of numbers, so where is the string?
Yara Hassan Moustafa
Yara Hassan Moustafa el 16 de Jun. de 2022
The data fo Power scenario is like the first picture and one cell of 373x7 is like the second picture. I want to export this data in an excel file.
DGM
DGM el 16 de Jun. de 2022
Editada: DGM el 16 de Jun. de 2022
Again, if the code is as shown and the data is being duplicated, why is any of this necessary?
Do you actually need 1000 (2000?) copies of the same data? If you don't, why not just open the .csv file in Excel and be done with it?
If the arrays are different, then how do you want to format the output?
Yara Hassan Moustafa
Yara Hassan Moustafa el 16 de Jun. de 2022
The arrays are differnet and the CSV files are written over each other, so i tried to export the file and then read it again to store the data in matlab. After that, i repeat the runs till i finish the number of samples that i am trying to collect data for.
Image Analyst
Image Analyst el 16 de Jun. de 2022
Editada: Image Analyst el 16 de Jun. de 2022
Can you zip up two of the csv files and attach the file with the paperclip icon?
Do you have only one CSV file? This one: 'ieee123_EXP_POWERS.CSV'?
Or are there many of them and the filename actually changes in your for loop?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 15 de Jun. de 2022

Editada:

el 16 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by