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.

 채택된 답변

Star Strider
Star Strider 2019년 3월 31일

0 개 추천

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

Say P
Say P 2019년 3월 31일
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 2019년 3월 31일
Thank you so much sir.
This worked.
Star Strider
Star Strider 2019년 3월 31일
As always, my pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2019년 3월 31일

댓글:

2019년 3월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by