フィルターのクリア

Read vectors into a matrix of NaNs??

1 回表示 (過去 30 日間)
Chelsey
Chelsey 2011 年 10 月 5 日
I have a large 25x25 matrix full of "NaN". I created it so that I could put several different 1-dimensional arrays of different lengths into one matrix together. But now I am having issues replacing the NaNs with the elements of the individual arrays.
For example, I have the big matrix "SalMat"
SalMat = repmat({NaN},25,25);
And I would like for sal01 to be the new first column of SalMat:
sal01 =
26.7762
26.7769
26.7773
26.7781
26.8047
27.0839
28.6000
30.5953
32.4578
33.2129
34.0983
34.4630
34.6466
34.6961
34.7120
34.7924
35.4376
35.5727
This would then be repeated with sal02,sal03,....sal25 inserted into the 25 columns of SalMat.
Any suggestions???

採用された回答

Sean de Wolski
Sean de Wolski 2011 年 10 月 5 日
repmat({nan},blah)
will replicate a cell of nan. You don't want cells ( doc cell, for more info). You want a regular matrix:
Salmat = nan(25); %same as repmat(nan,25,25);
Then do the insertions. Also read this FAQ4.6
  1 件のコメント
Chelsey
Chelsey 2011 年 10 月 5 日
Thank you!

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2011 年 10 月 5 日
SalMat = nan(25)
c = arrayfun(@(x)randi(randi(123),randi(25),1),1:25,'un',0)
for j1 = 1:size(SalMat,2)
SalMat(1:numel(c{j1}),j1) = c{j1};
end

カテゴリ

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