필터 지우기
필터 지우기

Store cells into Matrix

조회 수: 1 (최근 30일)
sita
sita 2013년 5월 13일
Hi, In below mentioned code i am trying to pair up all the elements in two matrices and trying to store in one matix.While storing overnested cells into variables matrix it does not store in proper order.Please help me in solving this . Thanks, Sita
clc;
clear;
countttest=0
p = haltonset(1) %'Skip',1e3,'Leap',1e2);
i1=1;
j1=3;
i2=1; j2=3; x1s(:,:)=p(i1:j1,:); x2s(:,:)=p(i2:j2,:); x1vals=x1s x2vals=x2s
[ii jj]=ndgrid(x1s,x2s);
overnested = arrayfun(@(x,y)[x y],ii,jj,'un',0)
celldisp(overnested)
for v2=i2:j2
for v1=i1:j1
variables(:,:,v1*v2)=overnested{v1,v2}
temp=variable
end
end
  댓글 수: 1
Jan
Jan 2013년 5월 13일
If you post code, which stores the data in an improper order, it is impossible to guess, what "proper" exactly is.
Beside the actually useless clc, it would be much more important to concentrate on the problem and format the code properly. It matters for the chance to get a useful answer, if you care about the readability of your code.

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

답변 (3개)

David Sanchez
David Sanchez 2013년 5월 13일
check out for that 3D array you call variables, Is it useful for anything? This same question was answered on Friday 10th.

Yao Li
Yao Li 2013년 5월 13일
Make sure each element in the cell variable has the same dimention. Assuming raw is the cell variable (1x2),x is the destination matrix, For example,
raw={3:7,6:10};
x(:,1)=raw{1,1};
x(:,2)=raw{1,2};
Then the 2 elements in raw are stored in two columns of the matrix x.

Andrei Bobrov
Andrei Bobrov 2013년 5월 13일
[ii jj]=ndgrid(x1s,x2s);
variables = permute([ii(:), jj(:)],[3 2 1]);

카테고리

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