Looping 100 elements at a time for an array

Greetings. I have just begun learning matlab, and I am trying to run a regress(y,x) for two arrays, x and y. In each array, there is 1000 numbers, and I am trying to take the regress(y,x) for the first hundred elements from each array, then the next hundred, then the next hundred, till the end of each list. How can I use a for loop to accomplish this task, so I do not have to individually find the regress() for each fifty element?
Thanks in advance

 採用された回答

Sebastian
Sebastian 2017 年 2 月 5 日

0 投票

I do not know how to work with regress() but applying a function to a section of a vector/matrix usually works like this:
x = rand(1, 1000);
y = rand(1, 1000);
for i = 1:100:1000
anyFunction(x(i:i+99), y(i:i+99))
end
There are numerous ways to achive this, though, but this is a good way to begin with.

1 件のコメント

Tom
Tom 2017 年 2 月 5 日
Thanks so much for your help. This is perfect

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

Tom
2017 年 2 月 5 日

コメント済み:

Tom
2017 年 2 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by