MATLAB: How to find derivative of CSV data plot csvderivative 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 % codeend Best Answer It is easiest to use the gradient (link) function:[D,S,R] = xlsread('Uniform_points.csv');t = D(:,1);f = D(:,2);dt = mean(diff(t));df = gradient(f,dt);figuresubplot(2,1,1)plot(t, f)gridtitle(S{2},'Interpreter','none')xlabel(S{1})subplot(2,1,2)plot(t, df)gridtitle(['d(',S{2},')/dt'],'Interpreter','none')xlabel(S{1}) Related SolutionsMATLAB: How can I get the square wave in matlab Try this:samples = 100;t = linspace(-5, 3, samples+1);f = 1*((t >= -5) & (t <= -1)) + (-1)*((t > -1) & (t <= 3)); figure(1)plot(t, f)axis([-5.5 3.5 -1.1 1.1])EDIT â Changed âtâ and axis limits to reflect edited limits (about 04:00 UCT 11 Mar 2018) in original Question. MATLAB: Add frequency scale for mesh This works:x=peaks;f=10; % freqfval=0:1:f;mesh(x)set(gca,'Ydir','reverse')ylabel('freq. Hz')xlabel('Samples')zlabel('Amp.')yt = get(gca,'YLim'); % Get Y-Limits Valuesdyt = 0:10; % Desired Y-Tick Valuesset(gca, 'YTick',linspace(min(yt),max(yt),length(dyt)), 'YTickLabel', dyt) % Set New Labels Related QuestionFft Invalid expression in plotHow to plot a graph along with axes graphRescale 2nd axis using yyaxis (Right Axis)Drawing plot based on integration of multivariablePlot: vertical legend for x axis
Best Answer