필터 지우기
필터 지우기

Having array trouble

조회 수: 2 (최근 30일)
reez all
reez all 2012년 4월 3일
i'm having trouble on manipulating the array form. according to the code below, i try to save the result inform of array so that it can be call outside the loop. but the size of or each row are different and the error appeared as:
Error using vertcat
CAT arguments dimensions are not consistent.
clear; clc;
DG = [0 1 0 0 0; 0 0 1 1 1; 0 0 0 0 1; 0 0 0 0 1; 0 0 0 0 0]
save=[];
for i = 1:5
child = find(DG(i,:))
save = [save; child];
end
can anyone help me to correct this problem, i'm really appreciate it. thank you..
  댓글 수: 3
reez all
reez all 2012년 4월 4일
thank you so much. But i cannot view the value of each row, i seem appeared as size of each row.
Andrei Bobrov
Andrei Bobrov 2012년 4월 4일
save1{:}

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

채택된 답변

Honglei Chen
Honglei Chen 2012년 4월 3일
Use cell
save = [save; {child}]
BTW I strongly suggest you to change the variable name, save, because it is one of MATLAB's function name.
  댓글 수: 3
Honglei Chen
Honglei Chen 2012년 4월 3일
you need to use {}, like disp(save{1}) or disp(save{:})
reez all
reez all 2012년 4월 4일
Thank you, for disp(save{:}) cannot been used, matlab appeared error, and i want to list all the result at one time.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by