how can i put the following code into a nested FOR loops

Hi, how can i put the following code into a nested FOR loops?
xu = [0:1];
yu = [0:1]';
[X, Y] = meshgrid(xu,yu);
prx(:,1) = [X(1,1); Y(1,1)]
prx(:,2) = [X(2,1); Y(2,1)]
prx(:,3) = [X(1,2); Y(1,2)]
prx(:,4) = [X(2,2); Y(2,2)]

 Akzeptierte Antwort

John D'Errico
John D'Errico am 18 Mär. 2017
Bearbeitet: John D'Errico am 18 Mär. 2017
Why would you want to use a for loop at all, when one line suffices for anything that you would loop over?
prx = [X(:),Y(:)];
Using nested loops to do this seems to be an abuse of MATLAB.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by