How can i automate the following process for n times?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone, how can i automate the following process for n times?
Thank you so much!
r=0.002
POINT1= [X, Y, Z];
POINT2= [POINT1(:,1), POINT1(:,2), r+POINT1(:,3)];
POINT3= [POINT2(:,1), POINT2(:,2), r+POINT2(:,3)];
POINTn= [POINTn-1(:,1), POINTn-1(:,2), r+POINTn-1(:,3)]
0 Commenti
Risposta accettata
Guillaume
il 21 Nov 2018
Never create numbered variables. It's a clear indication that you should be using an array, which can be easily indexed instead.
r = 0.002;
X = [0;1;2]; Y = [0;2;4]; Z = [0;-1;1];
n = 5;
Point = [X, Y, Z] + [0, 0, 1] .* (permute(0:n-1, [1, 3, 2]) * r)
Your
is now Point(:, :, i).
The above is just one of many ways of generating that 3d matrix.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!