How to convert cell char array in Table With Column

13 views (last 30 days)
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.
Hammad Younas
Hammad Younas on 2 Feb 2023
The data save in Table form like this one. I have attached the new data Please add code for this one

Sign in to comment.

Accepted Answer

KSSV on 2 Feb 2023
You can use regexp to extract the data.
[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});
T = table(predictedClass,maximumAmp,time)
Hammad Younas
Hammad Younas on 3 Feb 2023
@KSSV I am unable to do that, Thats why i posted the other question.
Can you please help me in that

Sign in to comment.

More Answers (0)


Find more on Tables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by