2

I'm trying to initialize an array in matlab of ninety zero's. However, I don't want to write 90 consecutive zeros after even = [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...... ] etc.

1
  • 1
    Welcome to StackOverflow! If you find an answer which you like, please accept it. For more information, check out the FAQ on the topic Commented Nov 7, 2011 at 11:08

1 Answer 1

9

Use the zeros function.

E.g. x = zeros(1,90)

Sign up to request clarification or add additional context in comments.

7 Comments

What about an array of ninety 42's? That is, is there a general form of zeros?
@pst: Use the ones function. x = 42*ones(1,90).
@pst: 42 * ones(1,90). Or repmat([1], 1, 90).
@pst: This is how we generate matrices of a single number. For more complicated replication, we use repmat.
@ Ben: you mean repmat([42], 1, 90) :)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.