Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Help with Matrix Summations

2 visualizaciones (últimos 30 días)
Peter cullen
Peter cullen el 27 de En. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi,
Below is an output from matlab. I wish to combine this into one matrix & add the three last terms of each elg_nl to the first three in the next elg_nl. How can this be done? The required solution is shown. I may also have more than 3 elg_nl, would I require a loop??
>> elg_nl
elg_nl(:,:,1) =
0
0
0
-6
-3
1
elg_nl(:,:,2) =
-5.0000
0.0000
7.5000
-5.0000
0.0000
7.5000
elg_nl(:,:,3) =
-6
-3
1
0
0
0
>> expected result (12x1matrix)
0
0
0
-11.0000
-3.0000
8.5000
-11.0000
-3.0000
8.5000
0
0
0
Please help, thanks

Respuestas (2)

Matt J
Matt J el 27 de En. de 2014
sum(elg_nl,3)
will produce the middle 6 elements you want. I don't know by what you rule you want it extended to 12x1, unless it's just zero padding.
  2 comentarios
Peter cullen
Peter cullen el 27 de En. de 2014
Thanks, I am trying to create a finite element code for a portal frame. The zeros indicate zero force at certain nodes and therefore are required. Any other ideas?
Matt J
Matt J el 27 de En. de 2014
Editada: Matt J el 27 de En. de 2014
No other ideas are required for any apparent reason. I've given you what you requested, as far as I can tell. I don't imagine you need help padding with zeros, if that's the only missing piece.

Amit
Amit el 27 de En. de 2014
eigen_nl_expected = [eigen_nl(:,:,1);eigen_nl(:,:,3)]
eigen_nl_expected(4:9) = eigen_nl_expected(4:9) + eigen_nl(:,:,2);

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by