Filter löschen
Filter löschen

any size of matrix

2 Ansichten (letzte 30 Tage)
Rutika Titre
Rutika Titre am 9 Dez. 2015
Beantwortet: Jon am 9 Dez. 2015
Hi! I have a matrix of 5X5 as my input matrix I want to create array of ones of 5X5 I=ones(length(M)); where M is my input matrix.If my input matrix is 7X9 I=ones(size(M)); is there any other way of writing it in more general form if we give any number of rows or columns. say I want to give 9X10 as my input matrix I want to create array of ones of 9X10.

Akzeptierte Antwort

Jon
Jon am 9 Dez. 2015
Kinda confusing what you're asking.
If your input matrix is M, just write
ones(size(M))
for a matrix of ones the same size as your input matrix.
If you don't have an input matrix to get the size, and want a matrix of ones that is 3 x 6, write
ones(3,6)
If I didn't answer your question, it's because it wasn't very clear. You should read this: http://www.mathworks.com/help/matlab/ref/ones.html

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by