필터 지우기
필터 지우기

Create array of all zeros

조회 수: 2 (최근 30일)
Maryam Hamrahi
Maryam Hamrahi 2016년 6월 13일
댓글: Azzi Abdelmalek 2016년 6월 13일
I use "zeros" to create a matrix with all zeros.
but I want to create matrix with all 0.0000
is there any way for doing this?
c=zeros(10,1);
I would like to have all 0.0000
Thank you very much

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 6월 13일
편집: Azzi Abdelmalek 2016년 6월 13일
c=zeros(10,1);
c=arrayfun(@(x) sprintf('%.4f',x),c,'un',0)
%or
c=zeros(10,1);
sprintf('%.4f\n',c)
  댓글 수: 4
Star Strider
Star Strider 2016년 6월 13일
It’s the aftermath!
Azzi Abdelmalek
Azzi Abdelmalek 2016년 6월 13일
@Maryam, If you don't want to print it, let it as it is, no one will see it!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Star Strider
Star Strider 2016년 6월 13일
They all are. What you see depends on the display format you choose.
To see all the zeros, type:
format long g
in the Command Window or in your script.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by