필터 지우기
필터 지우기

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 CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by