Limiting the number of rows of a vector

3 ビュー (過去 30 日間)
Giovanni
Giovanni 2013 年 12 月 11 日
編集済み: Azzi Abdelmalek 2013 年 12 月 11 日
Hi everyone, how do i limit a vector tC to only have 4 rows?

回答 (2 件)

Wayne King
Wayne King 2013 年 12 月 11 日
編集済み: Wayne King 2013 年 12 月 11 日
What size is tC now?
tC = randn(100,1);
tC = tC(1:4,1); %or tC = tC(1:4);
or
idx = 20;
tC = randn(100,1);
tC = tC(idx:idx+3);
Or are you asking how you keep a vector from being filled beyond 4 rows.

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 11 日
編集済み: Azzi Abdelmalek 2013 年 12 月 11 日
Your question is not clear. If you have a vector
v=[2 3 4 5 6 10]
This vector contains 6 element, you can extract the first four element
out=v(1:4); %but v still contains 6 element,
Or remove the others element of v
v(5:end)=[]
Maybe you should explain what you mean by limitation

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by