I just to confirm my syntax of abs and mode
1 view (last 30 days)
Show older comments
I have wrote it like this
x(mod(n, 2) == 0) = 5 * alpha .^ (abs(n(mod(n, 2) == 0))/2);
Is this one is right?
0 Comments
Answers (1)
Walter Roberson
on 19 May 2023
Not exactly.
syms alpha
n = [1 2 3 4 5]
x(mod(n, 2) == 0) = 5 * alpha .^ (abs(n(mod(n, 2) == 0))/2)
length(n)
length(x)
5 Comments
Walter Roberson
on 19 May 2023
By the way (hint):
[false false true false] .* [1 2 3 4]
Torsten
on 20 May 2023
n negative or 0 is not a problem for Zamer's code, as there is no indexing by n
I meant accessing the values of the sequence for n <= 0. The most natural way would be x(n) what does not work.
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!