Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How do I access data from an array using for statements?

조회 수: 1 (최근 30일)
Jose
Jose 2012년 11월 26일
마감: MATLAB Answer Bot 2021년 8월 20일
I have a vector called data the size of the vector is 15x2. The I want to extract the first column starting with the second row using for statements. I will keep adding more rows or will remove some with more data I get. I this is my code right now:
for x = data(2:length(data),[1,1]) %velocities
vels = x;
end
However I want to access each value one by one to plug into a formula. Is there a better way to do this?

답변 (1개)

Babak
Babak 2012년 11월 28일
z = [ones(15,1),2*ones(15,1)]
for j = 2:size(z,1)
vel = z(j,1); % element of jth row and 1st column
end

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by