フィルターのクリア

How to turn column y and row x vector into a matrix

9 ビュー (過去 30 日間)
noname
noname 2021 年 12 月 14 日
回答済み: Steven Lord 2021 年 12 月 14 日
Given: x = randn(1,20); y = randn(1,30);
I want to create a matrix B using x as row and y is column. I don't think B = y'.*x is correct since I want all the values are independently from x and y . Thanks!

回答 (1 件)

Steven Lord
Steven Lord 2021 年 12 月 14 日
How exactly should element B(r, c) be computed from the elements of x and y?
Rather than using random data, let x = 1:5 and y = 6:11. Show us the B matrix that those two vectors should generate and exactly the rule you follow in generating say B(2, 4).
If the elements in B aren't supposed to be related to the elements in x and y, and you just want to use x and y to indicate the size of the random B matrix to be created:
x = 1:5;
y = 6:11;
B = rand(numel(x), numel(y))
B = 5×6
0.9665 0.7759 0.4553 0.4837 0.9686 0.6334 0.2979 0.7615 0.6279 0.5339 0.4268 0.8626 0.8913 0.2618 0.1315 0.9079 0.6792 0.0591 0.4045 0.7560 0.9941 0.0921 0.9330 0.2042 0.3994 0.7670 0.8285 0.4071 0.4377 0.9883

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by