## How can I device a time series A by a Time series B if they are the same size?

Diego Dranuta

### Diego Dranuta (view profile)

님이 질문을 제출함. 20 Sep 2019
최근 활동 thoughtGarden

### thoughtGarden (view profile)

님이 댓글을 추가함. 24 Sep 2019
I have 2 time series, they are both the same size but I don't know how to devide time series A by time series B.
Also, Once is A/B. How can I get the max value regardless of time?
Thanks

로그인 to comment.

## 답변 수: 1

thoughtGarden

### thoughtGarden (view profile)

님의 답변 20 Sep 2019

Time series division is the same as general variable division
>> timeS1 = timeseries(linspace(1,2));
>> timeS2 = timeseries(linspace(1,5));
>> newSeries = timeS1/timeS2; %this works...
to find the max value, use the max() function
timeSeriesMax = max(newSeries);

표시 이전 댓글 수: 4
Diego Dranuta

### Diego Dranuta (view profile)

20 Sep 2019
in this case it would be if I am looking fot viualization of the difference. I just want the maximum percent difference in a scalar
thoughtGarden

### thoughtGarden (view profile)

20 Sep 2019
Then simply use the max() function.
% Build sample data using OP variable names
t = 1:.001:10;
out.Vehicle_Speed_mph = timeseries(abs(sin(t))+.1);
out.Driver_Speed_Desired_mph = timeseries(abs(cos(t))+.1);
% Compute Percent of Desired that has been achieved
percentOfDesired = 100.*(out.Vehicle_Speed_mph - out.Driver_Speed_Desired_mph)/out.Driver_Speed_Desired_mph;
% Plot Results
figure(1);clf;
subplot(2,1,1)
plot(out.Vehicle_Speed_mph,'displayName','Speed Achieved');
hold on;
plot(out.Driver_Speed_Desired_mph,'displayName','Speed Desired');
legend('show');
grid on;
title('Both Data Sets')
subplot(2,1,2)
plot(percentOfDesired,'displayName','Percent of Desired')
legend('show')
grid on;
title('The Percentage of Desired')
disp(['The Maximum percentage difference: ' num2str(max(percentOfDesired)) '%']);
thoughtGarden

24 Sep 2019