필터 지우기
필터 지우기

How do I add a set of points to a vector only using a while loop?

조회 수: 1 (최근 30일)
Andrew Padilla
Andrew Padilla 2018년 11월 2일
편집: madhan ravi 2018년 11월 2일
I am trying to create a nx2 vector that adds a set of two points, [2,1], for example. I listed my attempt below. For some reason, with what I have now, when I set X to zero (when I select no), the variables "values" only stores the last set of numbers. If anyone could guide me in the right direction, I would appreciate it.
if the user choose to run the program 3 times for example and enters the points [1, 2], [2, 3], [3, 4] on each run, how do I get the vector to store them like this
1 2
2 3
3 4
my attempt:
Y = [];
count = 0;
x = 1;
while x == 1
count = count + 1;
A = input('Input a set of points: ');
values = [[Y];A];
x = menu('Would you like to enter another set of points?','Yes','No');
end

답변 (1개)

madhan ravi
madhan ravi 2018년 11월 2일
편집: madhan ravi 2018년 11월 2일
Just change values to values(count)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by