フィルターのクリア

How to take user input values to create a row vector and column vector?

12 ビュー (過去 30 日間)
Rohit Sharma
Rohit Sharma 2020 年 5 月 3 日
コメント済み: Rohit Sharma 2020 年 5 月 3 日
I want to write a progam to create two vectors a & b where a is a row vector & b is a column vector. and multiply to create c = a*b.
The values of vector should be taken as user choice.
How I can define a matrix in which the values should be fill by user.
I have use input function but in this the values are not stored as matrix, as far as I am not asking user to put the values in[].
how can I directly put the values in matrix without asking them to write in[].
Thanks in advance.

採用された回答

Gautam
Gautam 2020 年 5 月 3 日
Try inputdlg instead.
a = str2num(char(inputdlg('Enter a: ')));
b = str2num(char(inputdlg('Enter b: ')));
c = a*b;
  1 件のコメント
Rohit Sharma
Rohit Sharma 2020 年 5 月 3 日
Hello Mr.Gautam,
Thank you for answering.
The code is doing the trick of taking user input values and creating vector.
But matrix b is stored as a row vector, so I have used another varible e=b' to transpose into column vector.
Also, to make the code more user friendly, I want to restrict the number of elements in matrix b to be equal to number of elements in matrix a after user input matrix a.
So as to fulfil matrix multiplication rule of number of columns= no of rows.
Please help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by