sobplot two matrix that the secend matrix is the same first matrix wtith shifts(only in x) on some parts of first matrix

1 次查看(过去 30 天)
There is a matrix (10000,2) first column is time and second is vales. it's needed to sobplot this with a second matrix. This second matrix is the same first matrix but i want do this changing : 1-i want some specified and defined parts(rows) of first matrix to be shifted and i have only value of time shifting
for example:
10 parts must be shifted that this number could be different in different cases
shiftTimeA=0.2 from 1 row to 500 in Matrix1 then:
Matrix2(1:1500,1)=Matrix1(1:1500,1)+shiftTimeA
shiftTimeB=0.3 from 3000 row to 6000 in Matrix1 then:
Matrix2(3000:6000,1)=Matrix1(3000:6000,1)+shiftTimeB
shiftTimeC=0.1 from 9000 row to 9500 in Matrix1 then:
Matrix2(9000:9500,1)=Matrix1(9000:9500,1)+shiftTimeC
.
.
.
.
shiftTimeJ (for part 10)
for other parts
Matrix2=Matrix1
now how could make this 10 parts in a loop(that this number could be different in different cases) and subplot 2 matrix in a figure

采纳的回答

Fangjun Jiang
Fangjun Jiang 2011-9-9
It could be put in a loop if you can explain what is the pattern for those index and shiftTime values, such as 1500, 3000, 6000, 9000, 9500, 0.2, 0.3, 0.1.
If there is no pattern, then your code looks good. There might be different approach, but not that different. One option:
ind=[1,1500,0.2;
3000,6000,0.3;
9000,9500,0.1];
Matrix2=zeros(size(Matrix1));
for k=1:size(ind,1)
Matrix2(ind(k,1):ind(k,2),1)=ind(k,3);
end
Matrix2=Matrix2+Matrix1;
  7 个评论

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by