How can I create a table or matrix of 193 rows and 117 columns?

1 回表示 (過去 30 日間)
Mariana
Mariana 2020 年 1 月 24 日
回答済み: Guillaume 2020 年 1 月 24 日
for i=0:115;x(1,i+1)=5+i;end
j = 1;
for i=10:200;v(j+1,1)= i; j =j+1;end
I want all the x values in columns -->116 values and v = 192 rows
The matrix has to be of 193 rows x 117 columns to have in the 1 column all the v values and start from the second column all the x values.
Like this:
0 5 6 7 9 8 10 11 . . . . . . . . 120
10
11
12
13
14
.
.
.
200

採用された回答

Guillaume
Guillaume 2020 年 1 月 24 日
Your description is really not clear and more importantly, it's very unlikely that what you're trying to do is the correct approach. It would be a good idea for you to explain what the ultimate goal is instead of the 1st step.
Also, you haven't said what should go in the rest of the matrix. I'm assuming 0s here:
desiredmatrix = [0, 5:120; [(10:200)', zeros(191, 116)]]
Another way:
desiredmatrix = zeros(192, 117);
desiredmatrix(1, 2:end) = 5:120;
desiredmatrix(2:end, 1) = 10:200;
You certainly don't need loops.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by