add elements to an existing vector
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a vector where I would like to add 5 NaN at the beginning. When I am doing it for one NaN, it's working fine, but not for five
This code worked fine:
lastDelta = [NaN;delta(1:end-1)];
and creates me a new vector that consists of one NaN and all the element of the existing vector delta except the last one
however, this code here is not working:
lastDelta = [NaN;NaN;NaN;NaN;NaN;delta(1:end-5)];
Has anybode an idea what I am missing?
0 件のコメント
採用された回答
Lam
2013 年 5 月 1 日
You mean adding or replacing?
This works for me:
delta = [1;2;3]
[NaN;NaN;NaN;NaN;NaN;delta(1:end)]
その他の回答 (1 件)
Youssef Khmou
2013 年 5 月 1 日
hi, try this :
R=rand(1,10); % initial vector
add=NaN*ones(1,5);
New=[add R];
参考
カテゴリ
Help Center および File Exchange で NaNs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!