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 ExchangeLoops 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