# Transfere an excel-list into vectors

3 Ansichten (letzte 30 Tage)
Benedikt Friedrich Nowak am 6 Feb. 2023
Hi there,
im trying to transfere an excel-list into many, specific vectors. Lets say i got three types of metal (x,y,z) and performed two different tests (1,2) on the metal itself. The Results were put in a an excel-list (Picture 1).
Now i read the excel-list into matlap ("readtable") and want to create different vectors for each metall and each test:
TypeX_Test1 = [1 2 3]
TypeX_Test2 = [7 8 9]
TypeY_Test1= [15 12 11]
and so on...
How do i make the vectors happen ?
Thank you for your time and help !
Ben
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Tushar Behera am 6 Feb. 2023
Hi Ben,
I believe you want to bundle up all the metal type and test number into one vector.
This can be acheived by using "regexp" function and by extracting the data from the table and split it into separate variables in MATLAB. I am assuming the table is similar to the picture you have provided. An example for the above workflow will be:
matchingRows = regexp(table.Var1, '^Test 1');
matchingRows = ~cellfun(@isempty, matchingRows);
TypeX_Test1 = table.TypeX(matchingRows);
TypeY_Test1 = table.TypeY(matchingRows);
TypeZ_Test1 = table.TypeZ(matchingRows);
matchingRows2 = regexp(table.Var1, '^Test 2');
matchingRows2 = ~cellfun(@isempty, matchingRows2);
TypeX_Test2 = table.TypeX(matchingRows2);
TypeY_Test2 = table.TypeY(matchingRows2);
TypeZ_Test2 = table.TypeZ(matchingRows2);
%%%%%%%%%%%%%%%%%%%%%%%%%%
Table after extraction
table =
6×4 table
Var1 TypeX TypeY TypeZ
____________ _____ _____ _____
{'Test 1.1'} 1 15 45
{'Test 1.2'} 2 12 42
{'Test 1.3'} 3 11 43
{'Test 2.1'} 7 19 89
{'Test 2.2'} 8 32 90
{'Test 2.3'} 9 18 78
Take a note that in this example the table contains a variable "Var1' which contains the test numbers.
I hope this resolves your query.
Regards,
Tushar
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Benedikt Friedrich Nowak am 6 Feb. 2023
Thank you !!

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Analysis of Variance and Covariance finden Sie in Help Center und File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!