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

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Guillaume
Guillaume il 24 Gen 2020
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.

Più risposte (0)

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Tag

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by