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

조회 수: 3 (최근 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]

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by