Cell array variable problem
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Marcelo Boldt
el 25 de Sept. de 2020
Comentada: Marcelo Boldt
el 25 de Sept. de 2020
Dear Community,
I am facing a rather basic problem but unfortunately I cannot fix it:
I have a nested loop that gives me as output a 324x324 cell that contains in each variable a associated matrix of 3x3. In addition, the important values are placed in the diagonal of the cell array, while the rest of the variables should be zero matrices of 3x3. the problem is that, I cannot assign the zero matrix to the remaining variables. The code goes as follow:
K_TANK_TOTAL = [K_tank_reinforcement;K_reinforcement;K_spherical_dome];
Structure_Global_Stiffness = cell(324,324);
Matrix_0 = zeros(3,3);
for kk = 1:324
for mm = 1:324
if (kk==1) && (kk==mm)
Structure_Global_Stiffness{kk,kk} = K_TANK_TOTAL{kk,1};
Structure_Global_Stiffness{kk,kk+1} = K_TANK_TOTAL{kk,2};
elseif (kk==mm) && (kk<98)
Structure_Global_Stiffness{kk,kk-1} = K_TANK_TOTAL{kk,1};
Structure_Global_Stiffness{kk,kk} = K_TANK_TOTAL{kk,2} + K_TANK_TOTAL{kk+1,1};
Structure_Global_Stiffness{kk,kk+1} = K_TANK_TOTAL{kk+1,2};
elseif (kk==mm) && (kk==98)
Structure_Global_Stiffness{kk,kk-1} = K_TANK_TOTAL{kk,1};
Structure_Global_Stiffness{kk,kk} = K_TANK_TOTAL{kk,2} + K_TANK_TOTAL{kk+1,1} + K_TANK_TOTAL{197,1};
Structure_Global_Stiffness{kk,kk+1} = K_TANK_TOTAL{kk+1,2};
Structure_Global_Stiffness{kk,kk+2} = K_TANK_TOTAL {197,2};
elseif (kk==mm) && (kk>98) && (kk<324)
Structure_Global_Stiffness{kk,kk-1} = K_TANK_TOTAL{kk,1};
Structure_Global_Stiffness{kk,kk} = K_TANK_TOTAL{kk,2} + K_TANK_TOTAL{kk+1,1};
Structure_Global_Stiffness{kk,kk+1} = K_TANK_TOTAL{kk+1,2};
elseif (kk==mm) && (kk==324)
Structure_Global_Stiffness{kk,kk-1} = K_TANK_TOTAL{kk,1};
Structure_Global_Stiffness{kk,kk} = K_TANK_TOTAL{kk,2};
else
Structure_Global_Stiffness{kk,zz} = Matrix_0; % HERE I HAVE MY PROBLEM
end
end
end
how can I solve this?
Thank you!
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Communications Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!