operations on two different matrices
이전 댓글 표시
I need to replace the first row from a matrix A(m.m) by first row from another matrix B(n.n) with different size?
채택된 답변
추가 답변 (1개)
Suppose ...
m = 3;
n = 4;
A = magic(m)
B = magic(n)
The first row of A is a 1x3 row vector, and the first row of B is a 1x4 row vector. What do you want the output to be? Also, what if m had been greater than n?
댓글 수: 6
Mohamed Hajjaj
2021년 9월 15일
the cyclist
2021년 9월 15일
Sorry, I still don't understand. Let's take a few specific cases. (The vectors represent the first row.) What should the output be in these cases?
Case 1
A = [8 1 6];
B = [16 2 3 13];
newA = [2 3 13]; % This is what you just said, so confident here.
Is the general rule that you take from the right-hand end?
Case 2
A = [16 2 3 13];
B = [8 1 6];
newA = ?; % What should it be?
Case 3
A = [30 39 48 1 10 19 28];
B = [8 1 6];
newA = ?; % What should it be?
Case 4
A = [8 1 6];
B = [30 39 48 1 10 19 28];
newA = ?; % What should it be?
I'm just trying to understand the general rule, and make sure it covers all possible cases.
Mohamed Hajjaj
2021년 9월 15일
Mohamed Hajjaj
2021년 9월 15일
the cyclist
2021년 9월 15일
Sorry, but your last two comments are just confusing to me.
You did not respond to my questions. What are the results for Case 1, Case 2, etc?
I don't know Fortran anymore, so cannot interpret that.
Why are you suddenly introducing new variables (D, DD1, idx)? Your original question seemed very simple, about filling in the first row of a matrix A, from the first row of a matrix B. It seems to be getting more and more complicated with every comment.
Mohamed Hajjaj
2021년 9월 16일
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!