a function generating a square matrix
Ältere Kommentare anzeigen
Hello!
I am trying to create a function who creating a matrix like that
A = [11 12 13 14]
[21 22 23 24]
[31 32 33 34]
[41 42 43 44]
And I have no idea how to do it, can someone could give me any tips?
How should I approach that?
Thank you!
Akzeptierte Antwort
Weitere Antworten (1)
Jorg Woehl
am 11 Mär. 2021
Bearbeitet: Jorg Woehl
am 11 Mär. 2021
A = [11, 12, 13, 14; 21, 22, 23, 24; 31, 32, 33, 34; 41, 42, 43, 44]
A comma (optional) starts a new column in a matrix, while a semicolon (required) starts a new row. See Get Started with MATLAB: Matrices and Arrays.
4 Kommentare
Thomas Kozinski
am 11 Mär. 2021
Jorg Woehl
am 11 Mär. 2021
I am not sure I understand what you are trying to do...
Thomas Kozinski
am 12 Mär. 2021
Jorg Woehl
am 12 Mär. 2021
Is there a particular reason that you need to use an (inefficient) loop instead of a simple assignment operation? If your question is related to a class assignment, please tag it as "homework".
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!