For loops and zero MATLAB experience

I have 700,2 data and need to use each of those rows of data as input to a function which will output 3,700. I can get my result just fine for a single 1,2 to 3,1, but cannot get the for loop expression correct. I've managed to waste nearly the entire day with this and am baffled. Especially so since I'm sure it's mind numbingly simple for even a user with minimal experience.

 채택된 답변

Matt Fig
Matt Fig 2011년 3월 22일

0 개 추천

.
.
.
EDIT I had that wrong. This should work:
A = rand(700,2);
B = zeros(3*700,700*3); % Store data here
cnt = 1;
for ii = 1:size(A,1)
B(cnt:cnt+2,:) = func(A(ii,:)); % Func returns 3-by-700
cnt = cnt + 3;
end

댓글 수: 1

Ian
Ian 2011년 3월 24일
Thanks Matt. I managed to hack away at other m-files and cobbled together something that isn't pretty but works. I modified the beginning of the good-single-data-item-output m-file with:
FP=[se_fault_segments(:,2) se_fault_segments(:,3)];
m=size(FP,1);
for k=1:m,
FP=[se_fault_segments(k,2) se_fault_segments(k,3)];
The FP element was the 700,2 [strike dip] I couldn't get completely processed and lead me to post my question. The se_fault_segments element is from a csv I load which has ID, strike, dip.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

Ian
2011년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by