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

1 vue (au cours des 30 derniers jours)
Mariana
Mariana le 24 Jan 2020
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

Réponse acceptée

Guillaume
Guillaume le 24 Jan 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.

Plus de réponses (0)

Catégories

En savoir plus sur Sparse Matrices dans Help Center et File Exchange

Tags

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by