a = ones(1,10);
b= zeros(1,10);
Take the codes above as an example, both of them are having 1*10 matrix. How do I change either one of them into 10*1 matrix?

1 件のコメント

Jan
Jan 2018 年 1 月 17 日
It is useful if you post, which command is failing.

サインインしてコメントする。

 採用された回答

Jan
Jan 2018 年 1 月 17 日

0 投票

You can multiply the vectors by
a * b.'
a.' * b
dot(a, b)

4 件のコメント

Alex Phang
Alex Phang 2018 年 1 月 17 日
編集済み: Alex Phang 2018 年 1 月 17 日
Take the example above, what about square of 'a' matrix? I have a error of
Inputs must be a scalar and a square matrix.
Jan
Jan 2018 年 1 月 17 日
@Alex: I cannot follow you. I asked for the failing command. It is much easier to solve a problem than to guess, what the problem is.
What does "Take the example above" mean? Do you mean:
a = ones(1,10);
b = zeros(1,10);
"what about square of 'a' matrix" ??? Do you want me to guess that you used:
a = ones(1,10);
c = a ^ 2
And if this causes an error, I could guess again that you meant:
a .^ 2
for an elementwise squaring. Please mention the details.
Alex Phang
Alex Phang 2018 年 1 月 17 日
編集済み: Alex Phang 2018 年 1 月 17 日
@Jan Simon: now my code is
c = a^2;
and the command is failing because of the
Inputs must be a scalar and a square matrix.
but using
c = a.^2
can worked.
Jan
Jan 2018 年 1 月 17 日
And maybe it creates the wanted result. It would be useful if you mention, what you want as result. Perhaps a * a.' is wanted.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

質問済み:

2018 年 1 月 17 日

コメント済み:

Jan
2018 年 1 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by