Completing elements of a matrix
古いコメントを表示
I have a matrix a
from a I have generated a new matrix b which have 2 new elements for 1 element of a
a = [2;3]
[m,n]=size(a)
for i=1:m
b=[1.5*(a(i)) 2*(a(i))]
end
I want to generate a new matrix 'c' such that it includes all the sets
expected results as
c = [2 3;2 4;3 4.5;3 6]
2 件のコメント
KSSV
2021 年 3 月 1 日
What is C? How you got it?
Karanvir singh Sohal
2021 年 3 月 1 日
編集済み: Karanvir singh Sohal
2021 年 3 月 1 日
採用された回答
その他の回答 (1 件)
Jan
2021 年 3 月 1 日
a = [2; 3];
b = [1.5; 2];
c = kron(a, [ones(size(a,1), 1), b])
5 件のコメント
Karanvir singh Sohal
2021 年 3 月 1 日
My code does solve the problem, which you have asked for in your question.
It would be useful, if you explain, what the actual problem is. Posting a specific problem, when you want to solve a general one wastes the time of the persons, who want to help you to solve your problem.
"Wont work" does not allow to understand, what you want to get as result instead.
Maybe you want:
c = kron(a, [ones(size(a)), b])
% or
c = [a, a(:) * b(:).']
Karanvir singh Sohal
2021 年 3 月 2 日
Karanvir singh Sohal
2021 年 3 月 2 日
Jan
2021 年 3 月 2 日
I do not get an idea of what you want to achieve.
カテゴリ
ヘルプ センター および File Exchange で GPU Computing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!