필터 지우기
필터 지우기

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개)

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by