[討論] [求救]nargin讀不出來
是這樣的,我的題目是:
Let x and y be column vectors describing the vertices of a polygon, given in
order. Write
functions polyperim(x,y) and polyarea(x,y) that compute the perimeter and
area of the polygon. For the area, use a formula below
http://twpic.org/uploads/43f9f3ad21.bmp
in which n is the number of polygon vertices, and by definition
我想說先輸入所有x座標 y座標 再來算
程式碼如下
n = input('number of polygon?')
xm = sparse(1,n)
ym = sparse(1,n)
cntx = 1
cnty = 1
while n< 1e+1000
xm(cntx) = input('enter x, enter to end')
%-------------------可是到這行就不能讀取了-----------------
if nargin==0
ym(cnty) = input('enter y, enter to end')
cnty = cnty + 1
if nargin == 0
for cntx = 1:n
for cnty = 1:n
polyarea = 0.5*abs(xm(cntx)*y(cnty+1)-x(cntx+1)*y(cnty))
end
end
end
end
cntx = cntx + 1
end
想請問各位大大可以幫我看一下嗎QAQ
感恩~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.7.214
→
03/21 00:32, , 1F
03/21 00:32, 1F
→
03/21 07:50, , 2F
03/21 07:50, 2F
→
03/21 07:51, , 3F
03/21 07:51, 3F