How to find derivative of CSV data plot?
    조회 수: 1 (최근 30일)
  
       이전 댓글 표시
    
I have a csv file with uniform points but i would like to write MATLAB code for obtain the derivative of the plotted function(unknown) with time. How can i do this?
if true
  % code
end
댓글 수: 0
채택된 답변
  Star Strider
      
      
 2018년 9월 28일
        [D,S,R] = xlsread('Uniform_points.csv');
t = D(:,1);
f = D(:,2);
dt = mean(diff(t));
df = gradient(f,dt);
figure
subplot(2,1,1)
plot(t, f)
grid
title(S{2},'Interpreter','none')
xlabel(S{1})
subplot(2,1,2)
plot(t, df)
grid
title(['d(',S{2},')/dt'],'Interpreter','none')
xlabel(S{1})
댓글 수: 6
  Star Strider
      
      
 2018년 9월 30일
				To simply alter the plot x-tick labels, this works:
t_new = 0:0.04:0.4;
figure
plot(t, f)
xt = get(gca, 'XTick');
xtv = linspace(min(xt), max(xt), numel(t_new));
set(gca, 'XTick', xtv, 'XTickLabel',t_new)
I generalised it, so it is a bit more complicated than it needs to be for the current values. It will work for other ‘t_new’ vectors without further modification.
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

