How to loop through and create an nx2 vector?

조회 수: 1 (최근 30일)
Bobalob
Bobalob 2015년 3월 1일
편집: per isakson 2015년 3월 1일
Hi there,
I have a function 'myfunction' that takes a single number as an input and returns a 1x2 vector. How do I perform a loop such that I can create an nx2 vector for multiple input values. I'm trying this but seem to be doing something wrong.
for i = 1:n
output(i) = [myfunction(i)];
end
thanks!

채택된 답변

per isakson
per isakson 2015년 3월 1일
편집: per isakson 2015년 3월 1일
Try
output = nan( 10, 2 );
for ii = 1:10
output(ii,:) = myfunction(ii);
end
and read

추가 답변 (0개)

카테고리

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