am trying to find the first and second derivates of a set of data points I've imported
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I am trying to find the first and second derivates of a set of data points I've imported. I tried using the diff function but that just gave me an error. Also how would i create two seperate plots for each differentiation operation?
Thank you
5 comentarios
dpb
el 24 de Abr. de 2019
Undefined function 'diff' for input arguments of type 'table'.
You insist on making it difficult by not providing sufficient information but M is the name of the overall table -- you've got to reference whatever particular variable it is out of the table to operate on...something like
dy=diff(M.X);
where X is the name of the variable you want to take difference of. Of, course, to actualy compute a derivative, you need the difference of both the displacement and time vectors if it were the velocity trying to compute--
v=diff(M.x)./diff(M.t);
Respuestas (1)
dpb
el 24 de Abr. de 2019
That's essentially trivial file that
data=csvread('data_10.csv');
data(:,2)=[nan;diff(data(:,1))]; % first difference
data(:,3)=[nan(2,1); diff(data(:,1),2)]; % second difference
will leave you with an array of three columns for data, first and second differences, respectively. The difference vectors are each one element shorter than the previous of course, so I used NaN as filler so plotting routines will ignore them silently. Since they're columns, simply
plot(data)
will plot all three on one axes; you can select columns as desired and/or use two axes or whatever for aesthetics as desired.
0 comentarios
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!