필터 지우기
필터 지우기

how do you define a matrix and its variable

조회 수: 2 (최근 30일)
Wenchen Liu
Wenchen Liu 2021년 11월 15일
댓글: Adam Danz 2021년 11월 15일
I want to create a matrix , by i * j, in matlab, and then let matlab run this. I need to tell matlab what is i and what is j before i define the matrix, right? Then when I define the matrix, can I write aMatrix = [i, j]?
I know how to do matrix like: aMatrix = [1 3 7 ; 5 6 7], but now I want to know how to make a general matrix by giving i and j in matlab.

답변 (1개)

Adam Danz
Adam Danz 2021년 11월 15일
편집: Adam Danz 2021년 11월 15일
Learn about preallocation.
Options:
i = 4;
j = 3;
M = nan(i,j)
M = 4×3
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
M = ones(i,j)
M = 4×3
1 1 1 1 1 1 1 1 1 1 1 1
M = zeros(i,j)
M = 4×3
0 0 0 0 0 0 0 0 0 0 0 0
  댓글 수: 4
Wenchen Liu
Wenchen Liu 2021년 11월 15일
but how could I define i?and should I define it before a and b?
Adam Danz
Adam Danz 2021년 11월 15일
Yes, just like in my demo.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Waveform Generation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by