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

DGM
DGM 2022년 6월 16일
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 2022년 6월 16일
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 2022년 6월 16일
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 2022년 6월 16일
편집: DGM 2022년 6월 16일
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 2022년 6월 16일
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 2022년 6월 16일
편집: Image Analyst 2022년 6월 16일
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?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2022년 6월 15일

편집:

2022년 6월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by