How insert this value
mb=[5 6 7 4 5 6 7 8 9 10 11 12 7 8 14 15 16 17 18 ...
7 8 19 21 23 25 27 29 7 20 22 24 26 28 1 2 1 2 1 2 1 2 1];
mb1=10*mb;
in the middle band
A=ones(8);
for i=1:4
for j=8-(i+2):8
A(i,j)=0;
end
end
for i=5:8
for j=1:8-(i-4)
A(i,j)=0;
end
end

 채택된 답변

Image Analyst
Image Analyst 2015년 4월 12일

0 개 추천

No one knows what you mean. You have two matrices, mb and mb1. And then you create a new matrix, A, that is all zeros. Do you want mb1 to come after row 4 of A and then A picks up again after MB1 is done? If so do
output = [A(1:4,:); mb1; A(5:end, :)];

추가 답변 (1개)

Reem Al Shehri
Reem Al Shehri 2015년 4월 12일

0 개 추천

the value middle band zeros replace this zeros to value vector after multiply vector of 10

댓글 수: 3

For replacement , rather than insertion , you'd want this:
A(5:6, :) = mb1; % Replace rows 5 and 6 with mb1
Reem's "Answer" moved here since it's not an "Answer" to the originally posted question:
This result
1 1 1 1 50 60 70 80
1 1 1 40 50 60 70 80
1 1 90 100 110 120 70 80
1 140 150 160 170 180 70 80
190 210 230 250 270 290 70 1
200 220 240 260 280 300 1 1
10 20 10 20 10 1 1 1
20 10 20 10 1 1 1 1
after insert value vector in middle band
Image Analyst
Image Analyst 2015년 4월 12일
I didn't know until I ran your code that the "band" is a group of 0's running diagonally from the upper right of the array to the lower left of the array. Anyway, do you have what you need now? If not, give the desired array after reading this.

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2015년 4월 12일

댓글:

2015년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by