Array Indices error while plotting an exponential function.
古いコメントを表示
I am tasked to plot a function f(t) = exp(10*t(t-1))*sin(20*pi*t) with 0 < t <= 1. Here is the code I made:
t=0:0.1:1;
f(t)=exp(10*t(t-1))*sin(20*pi*t);
plot(t,f(t))
But I get the error message:
Array indices must be positive integers or logical values.
Error in Homework_Assignment_2 (line 6)
f(t)=exp(10*t(t-1))*sin(20*pi*t);
During the lecture my Professor had no issue with having "x" or "t" increments starting with 0. Is there something wrong with my code?
3 件のコメント
dpb
2025 年 8 月 31 日
"Array indices must be positive integers..."
Your instructor used the value of t as the variable, not as an index into an array as you've written...
But, it's not at all clear to me just what was/is intended in the original equation of
f(t) = exp(10*t(t-1))*sin(20*pi*t)
with the t(t-1) expression.
Janeth
2025 年 8 月 31 日
Janeth
2025 年 8 月 31 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
