필터 지우기
필터 지우기

How can I break the two different ranges in the vector apart?

조회 수: 2 (최근 30일)
A C
A C 2018년 9월 16일
답변: Image Analyst 2018년 9월 16일
How can I break the two different ranges in the vector apart?
a = [7:17:302 primes(300)];
b = [7:17:302; primes(300)];
OR
b = [7:17:302];
c = [primes(300)];
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 9월 16일
What does it mean to break them apart?
The values 7 41 109 211 are in both ranges.
If you know the length of one of the two parts you can use indexing.
Image Analyst
Image Analyst 2018년 9월 16일
It looks like you did break them apart. Isn't that what b and c are? If not, then what are they?

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2018년 9월 16일
Do you perhaps mean this:
a = [7:17:302 primes(300)];
plot(a, 'b-', 'LineWidth', 2);
grid on;
index = find(diff(a) < 0);
b = a(1:index)
c = a(index+1:end)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by