필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can i write this in matlab please

조회 수: 1 (최근 30일)
Folakemi Omotoye
Folakemi Omotoye 2018년 8월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
this is the whole code
n=30;
[v]=linspace(3,20,n);
%CUSUM Algorithm
h=4; %threshold
t=2;
for t=2:numel(v) %start time
s(t)=sum(v(t-1)+v(t)); %cumulative sum up to current value
g(t)=max( s(2:t)); %maximum value
if g(t) > h %if output is greater than the specified threshold
detect_tim=t(g(t)>h); %store the detection time
disp(['The detection time= ', num2str(detect_tim),'']) %display the detection time
%estimate the change time
%%%i need help here please.(please refer to attached pic for analogy-signal.jpg) from the attached figure, i want to specify the time when the signal started increasing from zero (point 1000).the threshold is known (red line in the pic) but the assumption should be that the value zero is unknown (i.e the value zero should be the cumulative sum in previous lines of code).i want to specify the time the signal significantly started increasing from the cumulative sum up till the threshold
change_time=t(max(s(2:t))) ; %the time following the current minimum of
%the cumulative sum
disp(['The change time estimate= ', num2str(change_time),'']) %display value of change
% stop and reset algorithm
continue %to re-start algorithm
end
end
%Here, my xlim line doesnt get to the end of the length of the x-axis.it always stops at 1. i used auto because i don't know the last value of the x-axis. i want the horizontal line xl to extend till the end of the x-axis (signal plotpt1.jpg)
xL = get(gca,'XLim'); %plot threshold line on same axis
figure(1), subplot(2,1,1)
line(xL,[4 4],'Color','r'); %horizontal line through the threshold value
hold on
plot(2:t,v(2:t),'*b') %the time vector plot
title('signal change plot')
xlabel('time (ms)')
ylabel('Amplitude (v)')

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by