# Cut measured data, time series shifted

10 vues (au cours des 30 derniers jours)
Mark S le 5 Mai 2022
Commenté : Mark S le 9 Mai 2022
Hello, attached I have some measured data. I want now cut the data until 0,6 seconds.
So I want that the plot is beginning at 0,6 with the time 0 seconds. How I can do that
M = [M1];
% plot force data
subplot(2,1,1)
plot(M(:,1)/1000,M(:,2))
hold on
plot(M(:,1)/1000,M(:,3))
hold on
plot(M(:,1)/1000,M(:,4))
hold on
legend('Fx','Fy','Fz')
grid on
h_xlabel = xlabel ({ '\$t\$\,/\,s'});
set(h_xlabel,'Interpreter','latex');
h_ylabel = ylabel ({'\$F\$\,/\,N'});
set(h_ylabel,'Interpreter',' latex');
% plot torque data
subplot(2,1,2)
plot(M(:,1)/1000,M(:,5))
hold on
plot(M(:,1)/1000,M(:,6))
plot(M(:,1)/1000,M(:,7))
legend('Mx','My','Mz')
grid on
h_xlabel = xlabel ({ '\$t\$\,/\,s'});
set(h_xlabel,'Interpreter','latex');
h_ylabel = ylabel ({'\$M\$\,/\,Nmm'});
set(h_ylabel,'Interpreter',' latex');
grid on
h_xlabel = xlabel ({ '\$t\$\,/\,s'});
set(h_xlabel,'Interpreter','latex');
h_ylabel = ylabel ({'\$Weg\$\,/\,mm'});
set(h_ylabel,'Interpreter',' latex');
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Geoff Hayes le 5 Mai 2022
@Mark S - since the first column on M corresponds to time, and since you divide that column by 1000, you would want to find all or at least the first element of that column that is greater than or equal to 600 (as 600/1000 = 0.6). So you could do something like
firstIndexSatisfyingCondition = find(M(:,1) >= 600,1);
We need only consider the first index since we assume that the column values are in increasing order. Then you can do
% plot force data
subplot(2,1,1)
plot(M(firstIndexSatisfyingCondition:end,1)/1000,M(firstIndexSatisfyingCondition:end,2))
hold on
plot(M(firstIndexSatisfyingCondition:end,1)/1000,M(firstIndexSatisfyingCondition:end,3))
hold on
plot(M(firstIndexSatisfyingCondition:end,1)/1000,M(firstIndexSatisfyingCondition:end,4))
hold on
I haven't tried the above but I hope the idea is clear.
##### 3 commentairesAfficher 1 commentaire plus ancienMasquer 1 commentaire plus ancien
Geoff Hayes le 9 Mai 2022
@Mark S - won't that be misleading if you change the time (shift) from 0.6 to 0.0 seconds?
Mark S le 9 Mai 2022
I want manipulate my data. Because I have data where for example 100 seconds is happening nothing. So I want to cut this data and shift it to the left, so that it looks that the values change after some seconds after startup.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Logical dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by