How to convert cell char array in Table With Column
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hammad Younas
am 2 Feb. 2023
Kommentiert: Hammad Younas
am 3 Feb. 2023
Hello. I hope you are doing Well. I have import Data from website. I need to convert the Char array in Table with Values in Each Column
For Example In the following data I have 2x2 cell. The first Cell Predicted Class is the Column name and Airplane is the Value.
The second Cell will be Column name Maximum Amp and Time Value corresponding to there Values.
The C1 is the first Class and C2 is the Second Class so it should be in loop to save the data for multiple classes.
Can anybody help me with that.
2 Kommentare
Dyuman Joshi
am 2 Feb. 2023
y=load('Data.mat').Datawebsite
It's not clear how you want to store this data in Table. What is supposed to be the format of the Table? Direct conversion column wise?
out=cell2table(y)
Please give a sample output.
Akzeptierte Antwort
KSSV
am 2 Feb. 2023
load('Data.mat')
[m,n] = size(Datawebsite) ;
predictedClass = cell(m,1) ;
maximumAmp = zeros(m,1) ;
time = zeros(m,1) ;
expression1 = ':\s*(\w+)';
expression2 = '-?\d+\.\d+';
for i = 1:m
string1 = Datawebsite{i,1} ;
tokens = regexp(string1,expression1,'tokens');
predictedClass{i} = tokens{1}{1};
string2 = Datawebsite{i,2} ;
tokens = regexp(string2,expression2,'match');
maximumAmp(i) = str2double(tokens{1});
time(i) = str2double(tokens{2});
end
T = table(predictedClass,maximumAmp,time)
4 Kommentare
KSSV
am 3 Feb. 2023
You have the code for your asked case...you can extends the same to your case. It is straight forward.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!