How to define a range to iterate with gaps in between?

15 ビュー (過去 30 日間)
mathango
mathango 2016 年 5 月 3 日
回答済み: Azzi Abdelmalek 2016 年 5 月 3 日
Hi,
Is it possible to do iteration with gaps in simple and fast format in matlab.
For example,
i= 1:10;
j= 15:20;
k= 25:30;
goal => iterate M from 1 to 30 except at the gaps between 10 : 15, and 20 :25 .
The purpose of this is to avoid calling a function to iterate three times.

採用された回答

CS Researcher
CS Researcher 2016 年 5 月 3 日
Try this:
range = [1:10, 15:20, 25:30];

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 5 月 3 日
for k= [1:10 15:20 25:30]

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by