1xN matrix with input values

31 ビュー (過去 30 日間)
HYEON KYU LEE
HYEON KYU LEE 2017 年 12 月 2 日
編集済み: HYEON KYU LEE 2017 年 12 月 2 日
I have a question.
I would like to make 1xN row matrix (column vector is also ok)
A=[A1 A2 A3 .... AN] and
N=input('N?'); is needed.
and I will put the values each of the AN values.
A1=input('A1?') A2=input('A2?') ... AN=input('AN?') like this.
---------------------------------------------------------------
For example, when I put the value of N is 5 and A1=3, A2=2, A3=66, A4=1, A5=554 (can not put A6 and no more)
A=[A1 A2 A3 A4 A5]; => A=[3 2 66 1 554]
or input N=3 & A1=121 A2=2234 A3=3345 (can not put A4 and no more)
A=[A1 A2 A3] => A=[121 2234 3345];
process is like this.
This is very difficult for me . Help me please.

採用された回答

Birdman
Birdman 2017 年 12 月 2 日
N=input('Enter a number\n');
A=zeros(1,N);
for i=1:numel(A)
a=input('Enter a number\n');
A(i)=a;
end
What you ask for is this I guess :)
  1 件のコメント
HYEON KYU LEE
HYEON KYU LEE 2017 年 12 月 2 日
編集済み: HYEON KYU LEE 2017 年 12 月 2 日
Oh this is what i want! Thanks You are my savior :)

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by