How i can form Array List
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi,
I am new for mat-lab , how i can want to make Array List form ? below example
for int i=1:20
X = 1;
Y=2;
X1 =4;
Y2 =5;
X2 =6;
Y2 =7;
end
Output i would like to store like : matrix =[[1,2],[4,5],[6,7]];
채택된 답변
Walter Roberson
2014년 2월 17일
0 개 추천
MATLAB does not have array lists exactly like that. It has cell arrays which are similar.
matrix = {[X Y]; [X1 Y1]; [X2 Y2]}
댓글 수: 7
SAMEER ahamed
2014년 2월 17일
편집: SAMEER ahamed
2014년 2월 17일
Thanks for reply me . continuous looping values are stored in 8-by-1 matrix with comma any idea ?. below example like.
if true
% code
matrix=[[414, 313, 398, 313, 406, 293, 406, 314], [448, 317, 371, 312, 410, 293, 410, 329],
[412, 312, 397, 311, 405, 293, 405, 312], [414, 311, 395, 310, 405, 292, 405, 312],
[414, 310, 397, 310, 406, 292, 406, 312], [446, 314, 373, 309, 410, 291, 410, 326],
[448, 314, 371, 310, 410, 291, 410, 329], [412, 309, 392, 307, 402, 290, 402, 309],
[449, 313, 374, 282, 412, 289, 412, 323], [452, 311, 377, 307, 415, 288, 415, 327],
[446, 313, 370, 309, 408, 290, 408, 324]]];
end
numrow = 20;
matrix = cell(numrow, 20);
for Row = 1 : numrow
val1 = rand; val2 = rand; val3 = rand; vals = rand(5,1);
matrix{row} = [val1; val2; val3; vals];
end
Note that what you showed is a 1 x 8 rather than the 8 x 1 you indicate is required.
SAMEER ahamed
2014년 2월 17일
편집: Walter Roberson
2014년 2월 18일
Thank's for reply me . i have tried ,but i need to store single array cell?
I got result like :
Step 1 :
left_distance_X
22
left_distance_Y
19
right_distance_X
71
right_distance_Y
19
upper_distance_X
45
upper_distance_Y
6
right_distance_Y
45
bottom_distance_Y
35
Matrix
22
19
71
19
45
6
45
35
left_distance_X
26
left_distance_Y
23
right_distance_X
72
right_distance_Y
23
upper_distance_X
47
upper_distance_Y
11
right_distance_Y
47
bottom_distance_Y
36
Matrix
26
23
72
23
47
11
47
36
how to get single like : matrix =[[ 22,19,71,19,45,6,45,35],[26,23,72,23,47,11,47,36]];
Note: For that trainee data , pattern matching using machine algorithm weka and SVM .
SAMEER ahamed
2014년 2월 18일
편집: SAMEER ahamed
2014년 2월 18일
Thank's for reply me . please let me know how i can form like?for understanding please look at my previous forum?
if true
% code
matrix =[[ 22,19,71,19,45,6,45,35],[26,23,72,23,47,11,47,36]];
end
Walter Roberson
2014년 2월 18일
편집: Walter Roberson
2014년 2월 18일
You cannot get that. MATLAB does not support [[xxx]] notation for nested lists. The closest you can get is
matrix = cell(1, 2);
step = 1;
left_distance_X = 22;
left_distance_Y = 19;
right_distance_X = 71;
right_distance_Y = 19;
upper_distance_X = 45;
upper_distance_Y = 6;
right_distance_Y = 45;
bottom_distance_Y = 35;
matrix{1, step} = [left_distance_X, left_distance_Y, right_distance_X, right_distance_Y, upper_distance_X, upper_distance_Y, right_distance_Y, bottom_distance_Y];
step = 2;
left_distance_X = 26;
left_distance_Y = 23;
right_distance_X = 72;
right_distance_Y = 23;
upper_distance_X = 47;
upper_distance_Y = 11;
right_distance_Y = 47;
bottom_distance_Y = 36;
matrix{1, step} = [left_distance_X, left_distance_Y, right_distance_X, right_distance_Y, upper_distance_X, upper_distance_Y, right_distance_Y, bottom_distance_Y];
Note: this is not what SVM would use! SVM uses 2D numeric arrays, not list-of-arrays or nested-list. For 2D numeric arrays, use
matrix = zeros(2, 8);
step = 1;
left_distance_X = 22;
left_distance_Y = 19;
right_distance_X = 71;
right_distance_Y = 19;
upper_distance_X = 45;
upper_distance_Y = 6;
right_distance_Y = 45;
bottom_distance_Y = 35;
matrix(step,:) = [left_distance_X, left_distance_Y, right_distance_X, right_distance_Y, upper_distance_X, upper_distance_Y, right_distance_Y, bottom_distance_Y];
step = 2;
left_distance_X = 26;
left_distance_Y = 23;
right_distance_X = 72;
right_distance_Y = 23;
upper_distance_X = 47;
upper_distance_Y = 11;
right_distance_Y = 47;
bottom_distance_Y = 36;
matrix(step,:) = [left_distance_X, left_distance_Y, right_distance_X, right_distance_Y, upper_distance_X, upper_distance_Y, right_distance_Y, bottom_distance_Y];
SAMEER ahamed
2014년 2월 20일
편집: SAMEER ahamed
2014년 2월 20일
thank's for reply me , now i have got result like ?
if true
% code
for i=1:2
disp(matrix{1,i}); %here matrix{1,i}=[left_distance_X, left_distance_Y, right_distance_X, right_distance_Y, upper_distance_X, upper_distance_Y, right_distance_Y, bottom_distance_Y];
%Here result -1 like Matrix
30
23
77
23
53
8
53
35
%Here result-2 like
31
25
72
25
46
15
46
42
%Here I have tried up to int child node ,after looping of every 1-by-8 matrix
dt = datestr(now,'mm-dd-yy-HH:MM:SS.FFF-AM');
combinedStr = strcat('Hello',dt);
disp(combinedStr);
docNode = com.mathworks.xml.XMLUtils.createDocument('lipreading');
docRootNode = docNode.getDocumentElement;
thisElement = docNode.createElement('id');
thisElement.appendChild(docNode.createTextNode(combinedStr));
docRootNode.appendChild(thisElement);
matrix_thisElement = docNode.createElement('matrix');
vector_thisElement = docNode.createElement('vector');
left_int_thisElement = docNode.createElement('int');
*%Here I would like to call Looping stored each 1-by-8 matrix values*
docRootNode.appendChild(left_int_thisElement);
docRootNode.appendChild(vector_thisElement);
docRootNode.appendChild(matrix_thisElement);
xmlFileName =['tempname','.xml'];
xmlwrite(xmlFileName,docNode);
edit(xmlFileName);
end
end
*Note : I would like to write XML to form like below ?*
if true
% code
<vector>
<int>3</int>
<int>-99</int>
<int>-6</int>
<int>79</int>
<int>-195</int>
<int>11</int>
<int>197</int>
<int>8</int>
</vector>
<vector>
<int>4</int>
<int>-99</int>
<int>-5</int>
<int>79</int>
<int>-195</int>
<int>12</int>
<int>196</int>
<int>9</int>
</vector>
<vector>
end
Hi,
I am new for matlab , now i have 10 frames video file , each frame values i need to stored in xml file ?
I have Matlab Code Below like :
for i=1:10
matrix{1,i}=[leftx,lefty,rightx,righty,uppertx,uppery,bottomx,bottomy];%1-by-8 matrix
end
Below format i want to stored values please let me know how i can format like ?
example :
<reading>
<id>id1</id>
<matrix class="vector">
<vector>
<int>2</int>
<int>1</int>
<int>44</int>
<int>45</int>
<int>42</int>
<int>24</int>
<int>14</int>
<int>84</int>
</vector>
<vector>
<int>7</int>
<int>31</int>
<int>674</int>
<int>455</int>
<int>2</int>
<int>24</int>
<int>4</int>
<int>84</int>
</vector>
</matrix>
</reading>
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
태그
아직 태그를 입력하지 않았습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
