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.

 Akzeptierte Antwort

Matt Fig
Matt Fig am 22 Mär. 2011

0 Stimmen

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

Ian
Ian am 24 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

Ian
am 22 Mär. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by