i've created a function to gather x and y coordinates from user, but i dont know how to call them out in program
2 次查看(过去 30 天)
显示 更早的评论
function [abscissa,ordinate]=inputPoints(n)
clc;
s = 'Please enter points, one per point per line, in the form (#,#).';
disp(s);
for i = 1:n
enteredString = input('Point: ','s');
points(i,1:5) = sscanf(enteredString,'%c%d%c%d%c',[1,5]);
abscissa(i)=points(i,2);
ordinate(i)=points(i,4);
end
clc;
end
0 个评论
回答(1 个)
Matthew Eicholtz
2017-5-8
I'm not sure what you mean by "call them out in program", but you can call this function in the Command Window or in another script/function using:
[x,y] = inputPoints(4); % if I wanted 4 points, for example
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!