operations on two different matrices
13 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
採用された回答
Walter Roberson
2021 年 9 月 16 日
D0 j=1,8
A(1, j)=D(2,j+1)
end do
Acol = size(A,2);
A(1,:) = D(2,2:Acol+1);
vec = DD1(1,:);
A1(idx,:) = repmat(vec,numel(idx),1);
Acol = size(A,2);
vec = DD1(1,1:Acol);
A1(idx,:) = repmat(vec, numel(idx), 1);
その他の回答 (1 件)
the cyclist
2021 年 9 月 14 日
編集済み: the cyclist
2021 年 9 月 15 日
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 件のコメント
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.
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!