Borrar filtros
Borrar filtros

Transposing matrix of elements added by for loop

2 visualizaciones (últimos 30 días)
Kevin Burg
Kevin Burg el 27 de Jun. de 2021
Comentada: DGM el 28 de Jun. de 2021
I am creating a matrix with 38 unique entries. My for loop is creating a 1x38 matrix but I need it to be 38x1 for the operation I'm trying to perform. I tried using transpose but that did not work. How would I transpose this matrix so that I get each element added as a new row instead of a column? This is occuring on the Sol.RHS matrix
for i=1:inds.numinds
for j=1:inds.ind_dat(i).nconn
%
% gather the properties on both sides
%
jind=inds.ind_dat(i).conn_array(j).ind;
jsign=inds.ind_dat(i).conn_array(j).sign;
%
% indices for implicit contribution
%
ivmm=inds.numind*ind_scale_eq + (jind - 1) + 1;
%
% add in implicit and explicit terms - vapor
%
Sol.mat(ivmm,ivmm)=Sol.mat(ivmm,ivmm)+juns.jun_dat(jind).a*jsign/inds.ind_dat(i).volume;
Sol.RHS(ivmm)=transpose(Sol.RHS(ivmm)+juns.jun_dat(jind).a*jsign*inds.ind_dat(jind).vv/inds.ind_dat(i).volume);
end
end
  2 comentarios
Matt J
Matt J el 28 de Jun. de 2021
I tried using transpose but that did not work
It doesn't seem possible that that would not work.
DGM
DGM el 28 de Jun. de 2021
How exactly did it not work? Since there really isn't any information here about the size of any of these variables, I have no idea what would happen. All anyone can go on is your assertion that one of them is 1x38 -- something that any troubleshooting should question if array size/orientation is not meeting expectations. You might want to provide enough data or pseudo-data such that your code constitutes a minimal working example of your problem.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by