plot polygon function error

I want to draw polygon of some data Ki_bounds(:,1) ,Kp_range
I coded polygon function
function polygon( x,y )
function polygon( x,y )
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
plot(x,y)
axis([-1 1 -1.6 1])
end
then i called it in main
x=[ Ki_bounds(:,1); flipud(Ki_bounds(:,1))]
y=[Kp_range; flipud(Kp_range);];
poly_set= polygon(x,y);
but it gives error
Error using polygon
Too many output arguments.

回答 (1 件)

David Goodmanson
David Goodmanson 2019 年 12 月 22 日
編集済み: David Goodmanson 2019 年 12 月 22 日

0 投票

Hi msh,
the reason is pretty simple. You are asking for an output from the function, but you have not provided any in its definition.
Had you written
function z = polygon( x,y )
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
plot(x,y)
axis([-1 1 -1.6 1])
z = (whatever)
end
then the call would have worked. Or you can leave the function as is and just call it:
polygon(x,y)

1 件のコメント

Matt J
Matt J 2019 年 12 月 23 日
msh jgtu's answer converted to comment:
yes the function works without using z, the problem came when i use poly_set= polygon(x,y)
i want to use the polygon in Math operation so i used polyset this gives the error

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeElementary Polygons についてさらに検索

質問済み:

2019 年 12 月 22 日

コメント済み:

2019 年 12 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by