Reputation: 1214
I'm new to matlab, and in this academic exercise they asked us to do a sampling from a continuous function.
My original functions are:
x = sin(pi * t);
y = cos(2 * pi * t / 3);
z = x + y - 2;
In the interval
t = -8:0.001:8;
Then they asked us to make a sampling, z(n)
, of z
with a period of Ts=0.01
seconds.
My idea was to save in a new vector the values of z
, jumping through z
ten by ten positions:
n = numel(z);
Zd = z(0:10:z);
This idea came from the fact that 0.01 seconds is ten times less accurate then the first 'continuous' interval t
. But matlab says that this is not possible and gives me the error:
??? Subscript indices must either be real positive integers or logicals.
Can somebody give me some hint on this?
Upvotes: 2
Views: 6272
Reputation: 1214
As 2 @Memming said, matlab indexes start at 1 and not 0, and that was my problem.
Thanks.
Upvotes: 2