필터 지우기
필터 지우기

central difference method

조회 수: 10 (최근 30일)
abdulhadi khalifa
abdulhadi khalifa 2012년 4월 18일
편집: Muhammad Hammad Malik 2021년 2월 16일
How can I calculate the central difference for set of data using matlab If I have big data.Could any one help me to do it for this small data so I can I apply to my data X 0.225 0.30 0.35 0.40 0.45 0.475 Y 0.251 0.90 2.02 3.63 7.2 9.800

채택된 답변

Jan
Jan 2012년 4월 18일
You can simply use:
gradient(X, Y)
Then the first and the last element are forward and backward differences respectively. But all interior elements are central differences.
For large data sets FEX: DGradient is faster (10 to 16 times) than Matlab's gradient. In addition it can calulate the 2nd order approximation, when X is not uniformly distributed.
  댓글 수: 3
Jan
Jan 2021년 2월 15일
t = linspace(0, 2*pi, 1000);
x = sin(t);
dx = (x(11:5:end) - x(1:5:end-10)) / (10 * diff(t(1:2)));
plot(t(1:5:end-5), cos(t(1:5:end-5)), 'ro');
hold on
plot(t(5:5:end-10),dx)
Muhammad Hammad Malik
Muhammad Hammad Malik 2021년 2월 15일
편집: Muhammad Hammad Malik 2021년 2월 16일
@Jan thanks for the kind response. i have checked your code, but unable to understand well. why you use 11:5 and cos.
pls see what i have done, i am attaching here, the issue is i am unable to add window overlap.I also can change the window size to bigger or smaller, not restricted to use just 10.
The one you mentioned is working but how i can plot that with my time vector "IMU_ULISS.time" (1x25805), and i changed this time vector to plot mine as you can see.
Grad =gradient(Data_filtered(1:window:end),window)
figure;
plot(IMU_ULISS.time(1:window:end),Grad)
time_modified=IMU_ULISS.time(1:window:end)
hold onplot(time_modified(ceil(find(IMU_ULISS.step_instant_target(1,:)>0)/window)),Grad(ceil(find(IMU_ULISS.step_instant_target(1,:)>0)/window)),'r');
hold on

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

abdulhadi khalifa
abdulhadi khalifa 2012년 4월 18일
I want to calculate the slope by this method for y and X how I can do it
  댓글 수: 1
Jan
Jan 2012년 4월 18일
The output of GRADIENT *is* the slope. See my former answer.
It would be more helpful if you reply to the different ideas you got in your other postings concerning this problem. Simply posting the problem repeatedly in new threads wastes the time of all who want to assist.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by