To find the similar function
조회 수: 3 (최근 30일)
이전 댓글 표시
Is there a function (excluding the below) which can do similar task like:
y = zeros(1500,500);
댓글 수: 1
DGM
2022년 2월 26일
Are you asking for a replacement for zeros()?
If you are, that implies that there's a reason why zeros() can't be used. To recommend an alternative, one would have to know what those reasons are.
답변 (1개)
John D'Errico
2022년 2월 26일
Why would there be a different one? Do you really need multiple ways to do this, especially since any other way you would do it would be surely be more inefficient than just using zeros?
So is this a homework assignment, since this is exactly the kind of question we might see in a homework assignment? If so, is there a good reason why you did not tell us that?
I'll give you some hints. You could do it with repmat. You could use ones. You could even use repelem. You could even use toeplitz. Or you could use simple matrix indexing. There are many things you could do. But since this is surely homework, then it is something you need to think about, not be handed the solution.
댓글 수: 4
Walter Roberson
2022년 2월 26일
Also,
"You can add one or more elements to a matrix by placing them outside of the existing row and column index boundaries. MATLAB automatically pads the matrix with zeros to keep it rectangular."
Stephen23
2022년 2월 26일
편집: Stephen23
2022년 2월 26일
"Do you know how do we know about these functions?"
Using the MATLAB help:
- Scroll to the bottom of the ZEROS documentation, you will find links to related functions:

- while you have the ZEROS help open take a look at the browser panel on the left-hand side, then click on the last link before the function title, it will take you to a page with many more functions that create matrices in many different ways:

The MATLAB help is very large: the more you practice browsing it, the easier it will be to find information.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!