Want to create a time vector

1 回表示 (過去 30 日間)
Kyo Doe
Kyo Doe 2022 年 10 月 2 日
回答済み: Star Strider 2022 年 10 月 2 日
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?

回答 (1 件)

Star Strider
Star Strider 2022 年 10 月 2 日
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
.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by