Sampling Data (Urgent help needed)

5 vues (au cours des 30 derniers jours)
Feruz
Feruz le 17 Nov 2011
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

Réponses (1)

Wayne King
Wayne King le 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 commentaires
Feruz
Feruz le 17 Nov 2011
Thanks for answer...
Though, I want to check
vc = [];
if (x == 0.22)
vc = [vc U]
in that form, not by index, but by the value.
Making everything manually hurts, so that I was wondering or wanted to make it automate, so that in any value of x in that interval I can sample...
Walter Roberson
Walter Roberson le 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

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by