필터 지우기
필터 지우기

Empty Matrix: 1-by-0 error

조회 수: 1 (최근 30일)
KT
KT 2017년 3월 14일
답변: kowshik Thopalli 2017년 3월 15일
In MATLAB I am trying to create a vector, A, which goes from 2*pi to 7*pi in increments of pi/4. My code is as follows:
A = linspace((2*pi), (7*pi), (pi/4))
However when I push enter I get this message
A = Empty matrix: 1-by-0
How can I get around this error?

답변 (2개)

Walter Roberson
Walter Roberson 2017년 3월 14일
linspace's third argument is for the number of points to use. You used pi/4 which is 3.14.../4 which is less than 1.
You should use the colon operator
2*pi : pi/4 : 7*pi

kowshik Thopalli
kowshik Thopalli 2017년 3월 15일
help linspace()
y = linspace(x1,x2,n)
generates n points. The spacing between the points is (x2-x1)/(n-1). so here x1= 2*pi, x2=7*pi . Since the difference is pi/4 n=21;
so
A=linspace(2*pi,7*pi,21)
gives you what you want with the difference of pi/4

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by