Sampling Data (Urgent help needed)
2 views (last 30 days)
Show older comments
Hello, everybody,
I have a question regarding sampling data.
I have a case where I use
x = linspace(0, 1, N);
and after calculations I did plot of equation with, let say U
plot(x,U);
I want to sample data in long vector when x = 0.22 but let say with linspace I don't get this value, but in the plot I do have it. Note that function is time dependent, and I intend to use long vector with fft and plot...
Is there way to find or use plot or any trick to get what I want.
Thanks in advance.
Regards, Feruz
0 Comments
Answers (1)
Wayne King
on 17 Nov 2011
You can also change the increment between the values in your x vector so that you do have 0.22.
x = 0:.01:1-0.01;
U = exp(-x);
x(23)
U(23)
% or
x = linspace(0,0.99,100);
U = exp(-x);
x(23)
U(23)
2 Comments
Walter Roberson
on 17 Nov 2011
You are never going to get an x of exactly 0.22.
http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!