Hi,
I have an excel data which I am plotting in matlab as x- quantity= time and y-quantity= output. The y-quantity values are unevenly distributed w.r.t. x, i.e. the step size between x-quantity is not same. We know that matlab interpolates the unknown values between the known points to plot the graph.
How can I get these unknown values from the graph since I want the whole data to be equally distributed with specific step size.

 Respuesta aceptada

Star Strider
Star Strider el 31 de Mzo. de 2019

0 votos

You cannot get them from the plot, although you can calculate them.
To create a regularly-spaced time vector, used the linspace (link) function. To interpolate your y-values, use the interp1 (link) function.

4 comentarios

Say P
Say P el 31 de Mzo. de 2019
the linspace or interp1 functions give outputs for constant values(start and end), whereas I have a set of data where there are some output values of at various time values.
So, I don,t know how to use those functions for the same.
I have attached the excel sheet of the values with this comment.
Try this example:
[D,S] = xlsread('EXAMPLE.xlsx');
time = D(:,1);
angle = D(:,2);
tv = linspace(min(time), max(time), numel(time)*100);
anglv = interp1(time, angle, tv, 'linear');
figure
plot(time, angle, 'x')
hold on
plot(tv, anglv, '-r')
hold off
grid
It creates a new ‘time’ vector ‘tv’ from ‘time’ with 100 times as many points, then linearly interpolates the ‘angle’ values to get the ‘anglv’ vector. You can use other vectors for ‘tv’ and other interpolation methods if you want to. This is simply an illustration.
You can also use interp1 (over a narrow range of values) to get the inverse, that is the x-value in that range that corresponds to a specific y-value, regardless of the previously calculated values of ‘tv’ or ‘anglv’.
Say P
Say P el 31 de Mzo. de 2019
Thank you so much sir.
This worked.
Star Strider
Star Strider el 31 de Mzo. de 2019
As always, my pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 31 de Mzo. de 2019

Comentada:

el 31 de Mzo. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by