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.

 Réponse acceptée

Matt Fig
Matt Fig le 22 Mar 2011

0 votes

.
.
.
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 commentaire

Ian
Ian le 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by