# how do you define a matrix and its variable

5 vues (au cours des 30 derniers jours)
Wenchen Liu le 15 Nov 2021
Commenté : Adam Danz le 15 Nov 2021
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.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Adam Danz le 15 Nov 2021
Modifié(e) : Adam Danz le 15 Nov 2021
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 commentairesAfficher 2 commentaires plus anciensMasquer 2 commentaires plus anciens
Wenchen Liu le 15 Nov 2021
but how could I define i？and should I define it before a and b?
Adam Danz le 15 Nov 2021
Yes, just like in my demo.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Waveform Generation dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by