Ttest with two matrix
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi!
I have two datasets, both with 5 cell lines and 20 000 genes (20000x5). I now want to compare these two, since one is a control group and one has been treated with drugs. My plan was to use ttest, but it is not working. A error messages comes up that says:
Undefined operator '-' for input arguments of type 'table'.
Error in ttest (line 71)
x = x - m;
I have load up the two excel files by using spreadsheetDatastore, could that be the problem?
Thankful for any help :)
댓글 수: 0
답변 (1개)
Samayochita
2025년 4월 22일
Hi Mimmi,
It appears that the error is occurring because the “ttest” function in MATLAB expects numeric arrays as input, whereas the data is currently in the form of a table, which is the typical output format from “spreadsheetDatastore”.
To resolve this, the table data can be converted into a numeric array using the “table2array” function before passing to “ttest”.
Assuming the data is loaded as:
ds1 = spreadsheetDatastore('control.xlsx');
ds2 = spreadsheetDatastore('treated.xlsx');
Read the data as:
tbl1 = read(ds1);
tbl2 = read(ds2);
Now, convert the tables to numeric arrays (if the tables only contain numeric data):
X = table2array(tbl1);
Y = table2array(tbl2);
Finally, apply “ttest” by passing X and Y to the “ttest” function.
For more information on the functions mentioned above, please refer to following the documentation links:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!