How to generate a 1D array of zeros in Matlab?

262 views (last 30 days)
Devika Waghela
Devika Waghela on 24 Mar 2021
Commented: Jan on 6 Mar 2022
I want to create an 1D array of 100,000 elements in matlab full of zeros

Answers (2)

Jan
Jan on 24 Mar 2021
Edited: Jan on 24 Mar 2021
Please read the Getting Started chapters of the documentation and Matlab's Onramp: https://www.mathworks.com/learn/tutorials/matlab-onramp.html
It is not efficient if beginners ask all basic details in the forum.
x = zeros(1, 100000)
  2 Comments
José Montoya
José Montoya on 5 Mar 2022
What do you mean, not efficient? Let every detail be asked and every possible line on matlab show up on a google search!
The forum won't be crashing, and mathworks won't go broke on server space from a couple extra million questions.
Jan
Jan on 6 Mar 2022
@José Montoya: Asking a question in the forum means to wait 10 minutes to 3 days in average for the answer. Therefore reading the documentation are running the online tutorials is much more efficient for the users, because it is faster and clarifies dozens of standard questions in a compact way. Asking them all would takes weeks until a beginner can start to write useful codes. With the tutorials this takes 1 or 2 hours only.
Remember, that this forum does not live from questions only, but from the answers. The answering persons are volunteers and their time is valuable. Then asking for details, which are explained in the tutorials and manuals exhaustively already, is not efficient, but it wastes time, which could be spent in answers, which are not found elsewhere already.
"The forum won't be crashing" - I do disagree. The forum would crash, if all beginners ask for all details, because then the forum is to boring to particpate and filled with noise. This is not a question of the servers, but on the persons, who post answers in their sparetime.
Sometimes it more useful to tell a user, how he or she can solve the problems by their own. It is like telling someone how to fish, instead of giving one fish.
The top 10 answers have posted about 170'000 answers since this forum was started in 2009. Some million additional questions would kill the forum.
Feel free to give as many answers as you can, for advanced or beginner questions.

Sign in to comment.


William Rose
William Rose on 24 Mar 2021
data=zeros(100000,1); %column vector
data=zeros(1,100000); %row vector

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!