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.

 Risposta accettata

Matt Fig
Matt Fig il 22 Mar 2011
.
.
.
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 Commento

Ian
Ian il 24 Mar 2011
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by