write the next column of one array to the previous column of another array

조회 수: 1 (최근 30일)
Vecihi He
Vecihi He 2023년 1월 22일
답변: Sargondjani 2023년 1월 22일
if (k~=i)>0)
for l=1:L1
I(:,k,b) = aa(k,:,l,b)' ;
end
end
Here, for the case where k=i, 0 is entered in the kth column of the I matrix, but I don't want 0 to be entered and I want the next k+1 value of the aa matrix to be written in the kth column of the I matrix. So K=10 but I want to remove the case where k=i and make the size of the I matrix 9. How can I do this?
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 1월 22일
It is quite unclear what exactly you want to do.
"So K=10 but I want to remove the case where k=i and make the size of the I matrix 9."
For which matrix do you want to make the size 9? Which dimension of size? We don't know the size of arrays I and aa.
It will be better if you give a proper example with data of what you want to do.

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

답변 (1개)

Sargondjani
Sargondjani 2023년 1월 22일
One problem in your current code is that you are overwriting I(:,k,b) for every l. so you might as well use:
for l=L1
(instead of for l=1:L1 )
Anyway, i think you want something like
i2 = 0
for i=1:k
if (k~=i)
i2=i2+1
I(:,i2,b) = aa(i,:,l,b)' ;
end
end

카테고리

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