Forming a matrix

조회 수: 12 (최근 30일)
kash
kash 2012년 2월 20일
I want to form a matrix as below ,please help
istcolumn=
0.111
0.112
0.113
0.114
0.115
0.116
0.117
0.118
2nd column
0.119
0.1201
0.121
0.122
0.123
0.124
0.125
0.126
3rdcol
0.127
0.128
0.129
0.1301
0.131
0.132
0.133
0.134
4th
0.135
0.136
0.137
5th
0.138
0.139
6th
0.1401
0.141
0.142
0.143
0.144
0.145
0.146
0.147
please help

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 2월 20일
out = {[0.111
0.112
0.113
0.114
0.115
0.116
0.117
0.118],[0.119
0.1201
0.121
0.122
0.123
0.124
0.125
0.126],[0.127
0.128
0.129
0.1301
0.131
0.132
0.133
0.134],[0.135
0.136
0.137],[0.138
0.139],[0.1401
0.141
0.142
0.143
0.144
0.145
0.146
0.147]}
ADD
in matrix
N = cellfun(@numel,out);
out2 = zeros(max(N),numel(N));
for j1 = 1:numel(N)
out2(1:N(j1),j1) = out{j1};
end

추가 답변 (1개)

Jan
Jan 2012년 2월 20일
In a matrix all columns must have the same length. How do you want to pad e.g. the 5th column - by zeros or NaN's?
  댓글 수: 2
kash
kash 2012년 2월 21일
by zeros
Andrei Bobrov
Andrei Bobrov 2012년 2월 21일
see ADD in my answer

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by