Discretise into Equal Intervals
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
simply90
il 21 Gen 2014
Commentato: simply90
il 21 Gen 2014
I have an array of data, 2 columns and 19 rows of entries, which can be plotted as a loglog curve. However, the x-data I have does not have standard intervals and I need to approximate the curve as a piecewise linear function. Any suggestions as to how to go about this?
6 Commenti
Risposta accettata
Bruno Pop-Stefanov
il 21 Gen 2014
Modificato: Bruno Pop-Stefanov
il 21 Gen 2014
You can use several methods to interpolate data points from non-uniformly spaced points. There are listed here for one dimension:
vq = interp1(c, v, xq)
where x are the (non-uniformly spaced) input points (the first row in your vector) with values v (the second row in your vector), and xq are the query points (your uniformly spaced points). The function returns the interpolated values at xq in the vector vq.
For uniformly-spaced query points, you can use:
x_begin = x(1,1); % your 0.005
x_end = x(end,1); % your 2.13
numPoints = numel(x(:,1)); % number of points in your original vector; you can change that
xq = linspace(x_begin, x_end, numPoints);
for numPoints linearly spaced between x_begin and x_end. If you prefer to specify the length of each interval instead of the number of points, you could write:
xq = x_begin : int_length : x_end;
with int_length = 0.07.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!