Need a better way to loop through a Matrix column and then output the row
Mostrar comentarios más antiguos
I have a matrix (Nodal_Coordinates). I'm trying to loop through column 1 to find Node 1, Node 2... Node n. Then once Node_1 is found, I need it to display the respective row and only column 2 and column 3. The matrix row size can change with respect to the input, so it needs to be flexible on evaluating the matrix up to nth nodes. However, the columns will always be three. Col 1 is the node number, Col 2 is the x coordinate, Col 3 is the y coordinate. Below is the code I've been trying, but it outputs the entire row instead of just the 2nd and 3rd values of the row, and it's not flexible for nth rows... it only works for a fixed number of rows. Thanks for the help.
Nodal_Coordinates =
1 0 0
2 3 0
3 6 0
4 9 0
8 0 3
7 3 3
6 6 3
5 9 3
for i = Nodal_Coordinates(:,1)
for i = 1
Node_1 = Nodal_Coordinates(i,:)
for i = 2
Node_2 = Nodal_Coordinates(i,:)
for i = 3
Node_3 = Nodal_Coordinates(i,:)
for i = 4
Node_4 = Nodal_Coordinates(i,:)
for i = 5
Node_5 = Nodal_Coordinates(i,:)
for i = 6
Node_6 = Nodal_Coordinates(i,:)
for i = 7
Node_7 = Nodal_Coordinates(i,:)
for i = 8
Node_8 = Nodal_Coordinates(i,:)
end
end
end
end
end
end
end
end
end
1 comentario
Turlough Hughes
el 2 de Mzo. de 2020
Your code tells me you are quite new to matlab. I would recommend you do the introductory onramp course for matlab.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Share and Distribute Software en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!