Filling different size vectors with NaN

75 ビュー (過去 30 日間)
Inês Mendes
Inês Mendes 2015 年 7 月 6 日
コメント済み: Inês Mendes 2015 年 7 月 6 日
Hi guys!
I am having some trouble filling in a vector with NaN.
I have 2 vectors with different sizes, and i want to make them the same size, by adding NaN in the positions that don't have any value..
For example:
v=[1;2;3;4];
and
j=[5;6];
I want j to become:
j=[5;6;NaN;NaN];
Can anyone help?
Thanks in advance!
Inês

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 6 日
v=[1;2;3;4]
j=[5;6]
n=max(numel(v),numel(j))
v(end+1:n)=nan
j(end+1:n)=nan
  1 件のコメント
Inês Mendes
Inês Mendes 2015 年 7 月 6 日
Thank you so much Azzi!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by