# How to perform operations on time matrices

2 ビュー (過去 30 日間)
LORENZO DAVIDE DODI 2021 年 10 月 24 日
コメント済み: Stephen 2021 年 11 月 8 日
Ok so my problem stems from the analysis of measurements taken from images.
I have an excel sheet where I have a table of measurements where each column is a different cell (replicate) and the rows are the different time points in which the measurements were taken.
I now want to polish the data, exclude replicates (columns) when necessary and do multiple different operations with the values: i.e. calculating the mean value at time 1 between all of the columns and subtracting that to every element of the matrix; translate the column values to the top in order for them to start with the first positive number and eliminating any negative number after that by 'pushing together' the values below.
I.e. my matrix would be a = 0 2.3450 3.4570
1.0000 3.4670 4.8750
2.0000 4.6350 5.8350
I would first like to calculate the mean of the values of the first row (2.345 and 3.457) = 2.901
Then substract that to every value of the matrix i.e. a = 0 -0.5560 0.5560
1.0000 0.5660 1.9740
2.0000 1.7340 2.9340
Then I eliminate any negative value by filling the gaps with the lower values on the column i.e. a= 0 0.5660 0.5560
1.0000 1.7340 1.9740
2.0000 0 2.9340
If the matrix instead was c = 0 0.5660 0.5560
1.0000 1.7340 -1.6460
2.0000 0 2.9340
I would want the matrix to become c = 0 0.5660 0.5560
1.0000 1.7340 2.9340
2.0000 0 0
Is there any function or operation that could help me do those kind of modifications to the matrix?
Thank you!

サインインしてコメントする。

### 採用された回答

Stephen 2021 年 10 月 25 日
a = [0,2.3450,3.4570;1,3.4670,4.8750;2,4.6350,5.8350]
a = 3×3
0 2.3450 3.4570 1.0000 3.4670 4.8750 2.0000 4.6350 5.8350
m = a(:,2:end)-mean(a(1,2:end));
[~,x] = sort(m<0,1);
for k = 1:size(m,2)
m(:,k) = m(x(:,k),k);
end
a(:,2:end) = max(0,m)
a = 3×3
0 0.5660 0.5560 1.0000 1.7340 1.9740 2.0000 0 2.9340
##### 4 件のコメント表示非表示 3 件の古いコメント
Stephen 2021 年 11 月 8 日
"Would this be possible to tweak into the existing code"
You will need to generate a suitable matrix (it does not have to be a logical matrix) which somehow encodes the "criteria" that you want to sort based on (this itself might require a loop), and then SORT that matrix. Most likely the FOR-loop can stay much the same.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!

Translated by