フィルターのクリア

index no for iterations

1 回表示 (過去 30 日間)
Nitheesh M
Nitheesh M 2015 年 4 月 25 日
回答済み: Stephen23 2015 年 4 月 25 日
Attempted to access x(2,1.01); index must be a positive integer or logical.
Error in ==> latest at 19 dx1=x(2,i);
my code ::
for i = 0:0.01:2 yd(j) = sin(2*pi*i); j=j+1; dx1=x(2,i);
should i be integer values only..if then my yd will always be 0 right..i need values of yd from 0 to 2..and corresponding dx1...
please help me out

採用された回答

Stephen23
Stephen23 2015 年 4 月 25 日
You probably don't need a loop at all, and can simply vectorize the code anyway:
x = 0:0.01:2;
y = sin(2*pi*x);
and most likely any following value manipulations can also be vectorized. This is much faster and neater than using loops, which as something low-level programming languages rely on but are not a good use of MATLAB.

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by