Could anyone help me how to solve the following issue with respect to the following code
조회 수: 1 (최근 30일)
이전 댓글 표시
code:
a= [4.7908 5.0104 5.1329 5.3186 5.3094 5.3070 5.4452 5.5001;
0.0958 0.0994 0 0 0.1848 0.2020 0.1851 0.2146;
0.0848 0 0.1469 0.1859 0.1767 0.1854 0.1856 0.1648;
0 0 0 0 0 0 0 0;
0 0.0896 0.1619 0.1351 0 0 0 0;
0 0 0 0 0 0 0 0]
for i=1:size(a,2)
b=a(:,1:i)
iwant = reshape(b(randperm(numel(b))),size(b))
end
with respect to the code in for loop,
when the loop runs for the first time it takes the first column and reshape it and
when the loop runs for the second time it takes the first and second column and reshapes it.
But what i actually need is when the loop runs for the first time by taking the first column,reshape it ,should not be changed when the loop runs for the second time by taking the second column.
Could anyone please help me on it.
댓글 수: 0
답변 (1개)
KSSV
2019년 6월 3일
a=[ 4.7908 5.0104 5.1329 5.3186 5.3094 5.3070 5.4452 5.5001;
0.0958 0.0994 0 0 0.1848 0.2020 0.1851 0.2146;
0.0848 0 0.1469 0.1859 0.1767 0.1854 0.1856 0.1648;
0 0 0 0 0 0 0 0;
0 0.0896 0.1619 0.1351 0 0 0 0;
0 0 0 0 0 0 0 0] ;
[m,n] = size(a) ;
b = a ;
for i = 1:m
idx = randperm(n) ;
b(i,:) = a(i,idx) ;
end
댓글 수: 5
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!