Basically, I am trying to create an array that takes in the values generated by a function and place them in a predetermined size array.
j = j:1:(n-1);
bj = b0 + j*h;
I would like an array that has the size of 2xn. Meaning I would like it to have two columns and as many rows as the user inputs. My goal is to create an array that would look something like this;
bj = [1,2;3,4;5,6]
This would be useful to me because I plan on dividing all the values in one column by a value and the values in the other column by a different value, and then summing them both together.
I don't know if this came across as confusing but I essentially just want an array with 2 columns and a user specified number of rows to be filled up with values I generate in a loop.

 採用された回答

KSSV
KSSV 2016 年 11 月 2 日
編集済み: KSSV 2016 年 11 月 2 日

0 投票

bj = reshape(1:6,2,[])'
Let the user enter an even number 'n', you can frame your required matrix using:
bj = reshape(1:n,2,[])'

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

質問済み:

E
E
2016 年 10 月 31 日

編集済み:

2016 年 11 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by