Want to create a time vector

1 view (last 30 days)
Kyo Doe
Kyo Doe on 2 Oct 2022
Answered: Star Strider on 2 Oct 2022
Hello guys,
i got stuck in this one. I want to create a time vector like -10 <= t < 10 ( because using <= then i have to include -10 in t and not include 10 in t.)
i did something like:
t = -10:0.01:10;
stp = @(t) double(t>=0);
Is my code right?

Answers (1)

Star Strider
Star Strider on 2 Oct 2022
I have no idea what you want to do, although the linspace function may be a more precise approach —
t = -10:0.01:10-0.01 % 'colon'
t = 1×2000
-10.0000 -9.9900 -9.9800 -9.9700 -9.9600 -9.9500 -9.9400 -9.9300 -9.9200 -9.9100 -9.9000 -9.8900 -9.8800 -9.8700 -9.8600 -9.8500 -9.8400 -9.8300 -9.8200 -9.8100 -9.8000 -9.7900 -9.7800 -9.7700 -9.7600 -9.7500 -9.7400 -9.7300 -9.7200 -9.7100
t(end)
ans = 9.9900
t = linspace(-10, 9.99, 2000) % 'linspace'
t = 1×2000
-10.0000 -9.9900 -9.9800 -9.9700 -9.9600 -9.9500 -9.9400 -9.9300 -9.9200 -9.9100 -9.9000 -9.8900 -9.8800 -9.8700 -9.8600 -9.8500 -9.8400 -9.8300 -9.8200 -9.8100 -9.8000 -9.7900 -9.7800 -9.7700 -9.7600 -9.7500 -9.7400 -9.7300 -9.7200 -9.7100
t(end)
ans = 9.9900
.

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!