using diff or gradient function normalized the vector
조회 수: 1 (최근 30일)
이전 댓글 표시
for some reason when i use gradient function over a vector the scale get lowerd for example of sin function: the maximum is divided by 10 and in other cases the maximum is divided by something else
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148652/image.png)
댓글 수: 0
답변 (1개)
Jos
2015년 4월 4일
you have to divide by the time step. For instance, this gives you what you want
dt=0.1;
t=-2*pi:dt:2*pi;
subplot(3,1,1)
plot(t,sin(t))
subplot(3,1,2)
plot(t,gradient(sin(t),dt))
subplot(3,1,3)
plot(t(1:end-1),diff(sin(t))/dt)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!