フィルターのクリア

Change Matrix dimension with NaN

1 回表示 (過去 30 日間)
Inês Mendes
Inês Mendes 2015 年 7 月 22 日
編集済み: bio lim 2015 年 7 月 22 日
Hi guys,
After extracting some data the result is something like this:
h=[ 2 3 4, 5 6 , 7 8 9]
which is wrong and therefore an error appears because the matrix has to be square.
My question is, how can i fullfill the empty spaces in h with NaN.
Can anyone help?
Thanks in advance!
Inês
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 22 日
How your data are stored?

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

回答 (1 件)

bio lim
bio lim 2015 年 7 月 22 日
One possible solution is to use padcat function from file exchange.
a = [2 3 4]:
b = [5 6];
c = [7 8 9];
h = padcat(a,b,c)
And your h will be
h = [2 3 4; 5 6 NaN; 7 8 9]
  2 件のコメント
Inês Mendes
Inês Mendes 2015 年 7 月 22 日
yes i know that.... but i want a general solution like with a cycle in which i don´t have to manually put NaN in every single gap...
bio lim
bio lim 2015 年 7 月 22 日
編集済み: bio lim 2015 年 7 月 22 日
As Azzi mentioned, it would be difficult for us to look for a general solution unless we look at how your data were stored.

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by