필터 지우기
필터 지우기

generate a vector with a condition of a vector

조회 수: 2 (최근 30일)
Jeah MK
Jeah MK 2022년 2월 24일
답변: David Hill 2022년 2월 24일
I have a vector a
a = 1:1:20;
and each increment of a by 1 and a <= 10 creates a vector b with condition:
a = 1 => b = 1:1:10;
a = 2 => b = 2:1:10;
a = 3 => b = 3:1:10;
...
a = 10 => b = 10:1:10;
How to write a code to generate vector b ?
I have tried this, but it does not work.
if a<=1 && a<=10
b= a:1:10;
end

답변 (1개)

David Hill
David Hill 2022년 2월 24일
Hard to understand your question. You can generate a vector b anytime you want. If you want a cell array of all vector b's.
for k=1:10;
b{k}=k:10;
end

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by