Creating a matrix for each point point in a data set
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jeff C.
am 21 Feb. 2015
Kommentiert: Sad Grad Student
am 21 Feb. 2015
I am trying to create a new matrix for each point in a large dataset, but I am not sure how I can do this without writing out each one. From this dataset I have created an origin and three vectors for each point, and I need to put the origin and three vectors into a 4x4 identity matrix. Is there a way to do this using for loops?
2 Kommentare
Akzeptierte Antwort
Sad Grad Student
am 21 Feb. 2015
M = {}; % creating a cell array that will contain your 806 matrices
for i = 1:806
M{i} = eye(4,4);
M{i}(2:end,1) = o; % your vector of origins. o = [o1 o2 o3]
M{i}(2:end,2) = x; % your x vector. x = [x1 x2 x3]
M{i}(2:end,3) = y; % your y vector. y = [y1 y2 y3]
M{i}(2:end,4) = z; % your z vector. z = [z1 z2 z3]
end
2 Kommentare
Sad Grad Student
am 21 Feb. 2015
For cell, you need to ask for M{200}.. curly brackets instead of round.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!